]> mj.ucw.cz Git - libucw.git/commitdiff
Seek to end of an empty fbmem stream needs a special exception.
authorMartin Mares <mj@ucw.cz>
Fri, 12 Mar 2004 13:54:46 +0000 (13:54 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 12 Mar 2004 13:54:46 +0000 (13:54 +0000)
lib/fb-mem.c

index 2b0d7e941fa6cf1c9e0e408efe02a3a184bb67d8..daa807338301000882aa338cc5dc8ef1864619da 100644 (file)
@@ -120,6 +120,14 @@ fbmem_seek(struct fastbuf *f, sh_off_t pos, int whence)
          return;
        }
     }
+  if (!m->first && !pos)
+    {
+      /* Seeking to offset 0 in an empty file needs an exception */
+      f->buffer = f->bptr = f->bufend = NULL;
+      f->pos = 0;
+      FB_MEM(f)->block = NULL;
+      return;
+    }
   die("fbmem_seek to invalid offset");
 }