Fixed crash on zero-byte read/write (thanks, Ensiform!). stable-1.0
authorRyan C. Gordon <icculus@icculus.org>
Wed, 11 Jul 2007 22:11:29 +0000
branchstable-1.0
changeset 900 c5172fa2c5e6
parent 896 0895ab155ef1
child 902 a1bb05972265
Fixed crash on zero-byte read/write (thanks, Ensiform!).
CHANGELOG
physfs.c
--- a/CHANGELOG	Sat May 05 05:53:03 2007 +0000
+++ b/CHANGELOG	Wed Jul 11 22:11:29 2007 +0000
@@ -4,6 +4,7 @@
 
 -- stuff in the stable-1.0 branch, backported from 2.0.0 dev branch, etc ---
 
+07112007 - Fixed crash on zero-byte read/write (thanks, Ensiform!).
 05052007 - Fixed zip archiver: could do bogus seek if a small, non-zip file
            got put through isArchive().
 04022007 - Fixed Doxygen comment.
--- a/physfs.c	Sat May 05 05:53:03 2007 +0000
+++ b/physfs.c	Wed Jul 11 22:11:29 2007 +0000
@@ -1797,6 +1797,8 @@
     FileHandle *h = (FileHandle *) handle->opaque;
 
     BAIL_IF_MACRO(!h->forReading, ERR_FILE_ALREADY_OPEN_W, -1);
+    BAIL_IF_MACRO(objSize == 0, NULL, 0);
+    BAIL_IF_MACRO(objCount == 0, NULL, 0);
     if (h->buffer != NULL)
         return(doBufferedRead(handle, buffer, objSize, objCount));
 
@@ -1830,6 +1832,8 @@
     FileHandle *h = (FileHandle *) handle->opaque;
 
     BAIL_IF_MACRO(h->forReading, ERR_FILE_ALREADY_OPEN_R, -1);
+    BAIL_IF_MACRO(objSize == 0, NULL, 0);
+    BAIL_IF_MACRO(objCount == 0, NULL, 0);
     if (h->buffer != NULL)
         return(doBufferedWrite(handle, buffer, objSize, objCount));