diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index d00fe9ceb..79328ba93 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -678,7 +678,10 @@ static int32_t defsparser(scriptfile *script) artheader_t local; int32_t headerval = E_ReadArtFileHeader(fil, fn, &local); if (headerval != 0) + { + kclose(fil); break; + } if (havetile) { diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 9892651d8..1141e1076 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -9134,7 +9134,10 @@ int32_t loadboard(const char *filename, char flags, vec3_t *dapos, int16_t *daan { mapversion = 7; return -1; } if (kread(fil, &mapversion, 4) != 4) + { + kclose(fil); return -2; + } { int32_t ok = 0; diff --git a/source/build/src/lunatic.cpp b/source/build/src/lunatic.cpp index e609f8869..4df5ffd37 100644 --- a/source/build/src/lunatic.cpp +++ b/source/build/src/lunatic.cpp @@ -73,7 +73,10 @@ static int32_t read_whole_file(const char *fn, char **retbufptr) flen = kfilelength(fid); if (flen == 0) + { + kclose(fid); return 5; + } buf = (char *)Xmalloc(flen+1); diff --git a/source/build/src/tiles.cpp b/source/build/src/tiles.cpp index 260bf71f8..9f1c3aa55 100644 --- a/source/build/src/tiles.cpp +++ b/source/build/src/tiles.cpp @@ -440,7 +440,10 @@ static int32_t E_ReadArtFileOfID(int32_t tilefilei) artheader_t local; int const headerval = E_ReadArtFileHeader(fil, fn, &local); if (headerval != 0) + { + kclose(fil); return headerval; + } if (permap) { diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index c64798b90..55838ad77 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -295,6 +295,7 @@ int32_t Anim_Play(const char *fn) { OSD_Printf("Error initializing VPX codec.\n"); animvpx_restore_glstate(); + kclose(handle); return 0; } diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp index 07112ae8b..b4e6f62c4 100644 --- a/source/duke3d/src/savegame.cpp +++ b/source/duke3d/src/savegame.cpp @@ -166,7 +166,10 @@ static void ReadSaveGameHeaders_CACHE1D(CACHE1D_FIND_REC *f) if (k > 0) msv.isOldVer = 1; else + { + kclose(fil); continue; + } // else h.savename is all zeros (fatal failure, like wrong header // magic or too short header) }