diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/game_text.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/game/game_text.cpp b/src/game/game_text.cpp index 53c6795e9..cd9721b8a 100644 --- a/src/game/game_text.cpp +++ b/src/game/game_text.cpp @@ -81,9 +81,10 @@ LanguageStrings::~LanguageStrings() LanguageStrings *ReadRawLanguageStrings(const char *file) { LanguageStrings *ret = NULL; + FILE *fh = NULL; try { size_t to_read; - FILE *fh = FioFOpenFile(file, "rb", GAME_DIR, &to_read); + fh = FioFOpenFile(file, "rb", GAME_DIR, &to_read); if (fh == NULL) { return NULL; } @@ -96,7 +97,10 @@ LanguageStrings *ReadRawLanguageStrings(const char *file) } /* Check for invalid empty filename */ - if (*langname == '.' || *langname == 0) return NULL; + if (*langname == '.' || *langname == 0) { + fclose(fh); + return NULL; + } ret = new LanguageStrings(langname, strchr(langname, '.')); @@ -118,8 +122,10 @@ LanguageStrings *ReadRawLanguageStrings(const char *file) } } + fclose(fh); return ret; } catch (...) { + if (fh != NULL) fclose(fh); delete ret; return NULL; } |