fix resource leaks - issues 1034, 1038, 1040. Thanks to Martin Ettl

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@920 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
zdenop 2013-12-13 22:13:52 +00:00
parent b8d7a1d139
commit 9de80e0a06
3 changed files with 3 additions and 0 deletions

View File

@ -393,6 +393,7 @@ void TessBaseAPI::GetAvailableLanguagesAsVector(
} }
} }
} }
closedir(dir);
} }
#endif #endif
} }

View File

@ -408,6 +408,7 @@ bool MasterTrainer::LoadXHeights(const char* filename) {
} }
if (xheight_count == 0) { if (xheight_count == 0) {
fprintf(stderr, "No valid xheights in %s!\n", filename); fprintf(stderr, "No valid xheights in %s!\n", filename);
fclose(f);
return false; return false;
} }
int mean_xheight = DivRounded(total_xheight, xheight_count); int mean_xheight = DivRounded(total_xheight, xheight_count);

View File

@ -133,6 +133,7 @@ FILE *CharSampSet::CreateCharDumpFile(string file_name) {
// read and verify marker // read and verify marker
val32 = 0xfefeabd0; val32 = 0xfefeabd0;
if (fwrite(&val32, 1, sizeof(val32), fp) != sizeof(val32)) { if (fwrite(&val32, 1, sizeof(val32), fp) != sizeof(val32)) {
fclose(fp);
return NULL; return NULL;
} }
return fp; return fp;