r913 - branches/stable-1.0 trunk

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Jul 11 18:11:29 EDT 2007


Author: icculus
Date: 2007-07-11 18:11:29 -0400 (Wed, 11 Jul 2007)
New Revision: 913

Modified:
   branches/stable-1.0/CHANGELOG
   branches/stable-1.0/physfs.c
   trunk/CHANGELOG.txt
   trunk/physfs.c
Log:
Fixed crash on zero-byte read/write (thanks, Ensiform!).


Modified: branches/stable-1.0/CHANGELOG
===================================================================
--- branches/stable-1.0/CHANGELOG	2007-05-27 14:34:29 UTC (rev 912)
+++ branches/stable-1.0/CHANGELOG	2007-07-11 22:11:29 UTC (rev 913)
@@ -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.

Modified: branches/stable-1.0/physfs.c
===================================================================
--- branches/stable-1.0/physfs.c	2007-05-27 14:34:29 UTC (rev 912)
+++ branches/stable-1.0/physfs.c	2007-07-11 22:11:29 UTC (rev 913)
@@ -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));
 

Modified: trunk/CHANGELOG.txt
===================================================================
--- trunk/CHANGELOG.txt	2007-05-27 14:34:29 UTC (rev 912)
+++ trunk/CHANGELOG.txt	2007-07-11 22:11:29 UTC (rev 913)
@@ -2,6 +2,7 @@
  * CHANGELOG.
  */
 
+07112007 - Fixed crash on zero-byte read/write (thanks, Ensiform!).
 05272007 - FIXME removal: Replaced a strncpy() with a memcpy().
 05112007 - Minor documentation correction.
 05052007 - Fixed zip archiver: could do bogus seek if a small, non-zip file

Modified: trunk/physfs.c
===================================================================
--- trunk/physfs.c	2007-05-27 14:34:29 UTC (rev 912)
+++ trunk/physfs.c	2007-07-11 22:11:29 UTC (rev 913)
@@ -1978,6 +1978,8 @@
     FileHandle *fh = (FileHandle *) handle;
 
     BAIL_IF_MACRO(!fh->forReading, ERR_FILE_ALREADY_OPEN_W, -1);
+    BAIL_IF_MACRO(objSize == 0, NULL, 0);
+    BAIL_IF_MACRO(objCount == 0, NULL, 0);
     if (fh->buffer != NULL)
         return(doBufferedRead(fh, buffer, objSize, objCount));
 
@@ -2011,6 +2013,8 @@
     FileHandle *fh = (FileHandle *) handle;
 
     BAIL_IF_MACRO(fh->forReading, ERR_FILE_ALREADY_OPEN_R, -1);
+    BAIL_IF_MACRO(objSize == 0, NULL, 0);
+    BAIL_IF_MACRO(objCount == 0, NULL, 0);
     if (fh->buffer != NULL)
         return(doBufferedWrite(handle, buffer, objSize, objCount));
 




More information about the physfs-commits mailing list