From ea748cfdbdfbca55070f8a7124770b9845812102 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Thu, 31 Jul 2008 21:08:00 +0000 Subject: [PATCH] Fixed a few file handle leaks --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402432 --- core/GameConfigs.cpp | 1 + core/systems/PluginSys.cpp | 2 ++ sourcepawn/jit/engine2.cpp | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/core/GameConfigs.cpp b/core/GameConfigs.cpp index 4f5e0048..788e31a9 100644 --- a/core/GameConfigs.cpp +++ b/core/GameConfigs.cpp @@ -236,6 +236,7 @@ SMCResult CGameConfig::ReadSMC_NewSection(const SMCStates *states, const char *n s_ServerBinCRC = UTIL_CRC32(buffer, size); free(buffer); s_ServerBinCRC_Ok = true; + fclose(fp); } } if (error[0] != '\0') diff --git a/core/systems/PluginSys.cpp b/core/systems/PluginSys.cpp index 64377f99..e75e0a27 100644 --- a/core/systems/PluginSys.cpp +++ b/core/systems/PluginSys.cpp @@ -169,6 +169,8 @@ CPlugin *CPlugin::CreatePlugin(const char *file, char *error, size_t maxlength) return pPlugin; } + fclose(fp); + return pPlugin; } diff --git a/sourcepawn/jit/engine2.cpp b/sourcepawn/jit/engine2.cpp index aa69bbc1..6684af81 100644 --- a/sourcepawn/jit/engine2.cpp +++ b/sourcepawn/jit/engine2.cpp @@ -141,6 +141,7 @@ IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file if (hdr.magic != SPFILE_MAGIC) { error = SP_ERROR_FILE_FORMAT; + fclose(fp); goto return_error; } @@ -167,6 +168,7 @@ IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file free(sectheader); free(uncompdata); error = SP_ERROR_DECOMPRESSOR; + fclose(fp); goto return_error; } @@ -188,10 +190,13 @@ IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file default: { error = SP_ERROR_DECOMPRESSOR; + fclose(fp); goto return_error; } } + fclose(fp); + plugin = new sp_plugin_t; memset(plugin, 0, sizeof(sp_plugin_t));