Skip to content
Permalink
Browse files
Fixed crash on zero-byte read/write (thanks, Ensiform!).
  • Loading branch information
icculus committed Jul 11, 2007
1 parent c27fd96 commit c5ee3d965c8a324b926789edfee21ada1ef30391

File 2 of 2 in c5ee3d9

@@ -1978,6 +1978,8 @@ PHYSFS_sint64 PHYSFS_read(PHYSFS_File *handle, void *buffer,
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 @@ PHYSFS_sint64 PHYSFS_write(PHYSFS_File *handle, const void *buffer,
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));

0 comments on commit c5ee3d9

Please sign in to comment.