From c27d7f916f611b66156d1d629534d866182b87dd Mon Sep 17 00:00:00 2001 From: Jaime Ita Passos <jp6781615@gmail.com> Date: Thu, 11 Aug 2022 04:30:03 -0300 Subject: [PATCH] Stop -Wuse-after-free warnings --- src/filesrch.c | 2 +- src/w_wad.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/filesrch.c b/src/filesrch.c index ec095518e8..3f901b6958 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -712,9 +712,9 @@ lumpinfo_t *getdirectoryfiles(const char *path, UINT16 *nlmp, UINT16 *nfolders) // Close any open directories and return if something went wrong. if (failure) { + for (; depthleft < maxdirdepth; closedir(dirhandle[depthleft++])); free(dirpathindex); free(dirhandle); - for (; depthleft < maxdirdepth; closedir(dirhandle[depthleft++])); return NULL; } diff --git a/src/w_wad.c b/src/w_wad.c index cf954a55ea..368a879a4e 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -641,8 +641,6 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) lump_p->fullname = Z_Calloc(zentry.namelen + 1, PU_STATIC, NULL); strncpy(lump_p->fullname, fullname, zentry.namelen); - free(fullname); - switch(zentry.compression) { case 0: @@ -662,6 +660,8 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) break; } + free(fullname); + // skip and ignore comments/extra fields if (fseek(handle, zentry.xtralen + zentry.commlen, SEEK_CUR) != 0) { -- GitLab