Skip to content

Commit

Permalink
Fixed mishandling of an allocation failure in PHYSFS_openRead().
Browse files Browse the repository at this point in the history
(Static analysis caught this one! Thanks clang!)
  • Loading branch information
icculus committed May 12, 2020
1 parent 291cad0 commit 235e31c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/physfs.c
Expand Up @@ -2731,13 +2731,15 @@ PHYSFS_File *PHYSFS_openRead(const char *_fname)
io->destroy(io);
PHYSFS_setErrorCode(PHYSFS_ERR_OUT_OF_MEMORY);
} /* if */

memset(fh, '\0', sizeof (FileHandle));
fh->io = io;
fh->forReading = 1;
fh->dirHandle = i;
fh->next = openReadList;
openReadList = fh;
else
{
memset(fh, '\0', sizeof (FileHandle));
fh->io = io;
fh->forReading = 1;
fh->dirHandle = i;
fh->next = openReadList;
openReadList = fh;
} /* else */
} /* if */
} /* if */

Expand Down

0 comments on commit 235e31c

Please sign in to comment.