Changeset - r21013:2da6197c9828
[Not reviewed]
master
0 1 0
rubidium - 11 years ago 2013-11-24 15:25:41
rubidium@openttd.org
(svn r26090) -Fix: leaking of file descriptor when reading strings for game texts
1 file changed with 8 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/game/game_text.cpp
Show inline comments
 
@@ -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(
 
		}
 

	
 
		/* 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(
 
			}
 
		}
 

	
 
		fclose(fh);
 
		return ret;
 
	} catch (...) {
 
		if (fh != NULL) fclose(fh);
 
		delete ret;
 
		return NULL;
 
	}
0 comments (0 inline, 0 general)