diff --git a/api/baseapi.cpp b/api/baseapi.cpp index b4f06a790..cd9e4aae1 100644 --- a/api/baseapi.cpp +++ b/api/baseapi.cpp @@ -393,6 +393,7 @@ void TessBaseAPI::GetAvailableLanguagesAsVector( } } } + closedir(dir); } #endif } diff --git a/classify/mastertrainer.cpp b/classify/mastertrainer.cpp index 7726814fa..8a49baf06 100644 --- a/classify/mastertrainer.cpp +++ b/classify/mastertrainer.cpp @@ -408,6 +408,7 @@ bool MasterTrainer::LoadXHeights(const char* filename) { } if (xheight_count == 0) { fprintf(stderr, "No valid xheights in %s!\n", filename); + fclose(f); return false; } int mean_xheight = DivRounded(total_xheight, xheight_count); diff --git a/cube/char_samp_set.cpp b/cube/char_samp_set.cpp index 65caa397a..2a495095e 100644 --- a/cube/char_samp_set.cpp +++ b/cube/char_samp_set.cpp @@ -133,6 +133,7 @@ FILE *CharSampSet::CreateCharDumpFile(string file_name) { // read and verify marker val32 = 0xfefeabd0; if (fwrite(&val32, 1, sizeof(val32), fp) != sizeof(val32)) { + fclose(fp); return NULL; } return fp;