From 235e31c420a8ba05d7281bcf502b0f15ded1cfc5 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 12 May 2020 15:19:01 -0400 Subject: [PATCH] Fixed mishandling of an allocation failure in PHYSFS_openRead(). (Static analysis caught this one! Thanks clang!) --- src/physfs.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/physfs.c b/src/physfs.c index eec40b2b..1e64b2b1 100644 --- a/src/physfs.c +++ b/src/physfs.c @@ -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 */