shithub: dumb

Download patch

ref: b837698bcffa3952e5fa26e80ffc562e961002b9
parent: 690b8c607fa01df486f00af03b068d11acd14d55
author: Chris Moeller <kode54@gmail.com>
date: Sat Dec 22 14:15:19 EST 2012

Fixed memory reader for formats which perform empty skips at the end of the file, like Asylum AMF

--- a/dumb/src/it/readany.c
+++ b/dumb/src/it/readany.c
@@ -34,7 +34,6 @@
 {
     unsigned char *buffered;
     long ptr, len;
-    DUMBFILE *remaining;
 };
 
 
@@ -47,11 +46,11 @@
         if (bm->ptr >= bm->len) {
             free(bm->buffered);
             bm->buffered = NULL;
-            return dumbfile_skip(bm->remaining, bm->ptr - bm->len);
+            return (bm->len - bm->ptr);
         }
         return 0;
     }
-    return dumbfile_skip(bm->remaining, n);
+    return n ? -1 : 0;
 }
 
 
@@ -67,7 +66,7 @@
         }
         return rv;
     }
-    return dumbfile_getc(bm->remaining);
+    return -1;
 }
 
 
@@ -81,18 +80,13 @@
             memcpy(ptr, bm->buffered + bm->ptr, left);
             free(bm->buffered);
             bm->buffered = NULL;
-            if (n - left) {
-                int rv = dumbfile_getnc(ptr + left, n - left, bm->remaining);
-                return left + MAX(rv, 0);
-            } else {
-                return left;
-            }
+            return left;
         }
         memcpy(ptr, bm->buffered + bm->ptr, n);
         bm->ptr += n;
         return n;
     }
-    return dumbfile_getnc(ptr, n, bm->remaining);
+    return 0;
 }
 
 
@@ -101,7 +95,6 @@
 {
     BUFFERED_MOD *bm = f;
     if (bm->buffered) free(bm->buffered);
-    /* Do NOT close bm->remaining */
     free(f);
 }
 
@@ -159,8 +152,6 @@
         free(bm->buffered);
         bm->buffered = NULL;
     }
-
-    bm->remaining = f;
 
     return dumbfile_open_ex(bm, &buffer_mod_dfs);
 }