Merge pull request #446 from stweil/cov

Fix some resource leaks reported by Coverity
This commit is contained in:
zdenop 2016-10-24 20:45:42 +02:00 committed by GitHub
commit 3eb044bc60
6 changed files with 16 additions and 1 deletions

View File

@ -2113,6 +2113,7 @@ void ConvertHypothesizedModelRunsToParagraphs(
if ((*row_owners)[row] != NULL) {
tprintf("Memory leak! ConvertHypothesizeModelRunsToParagraphs() called "
"more than once!\n");
delete (*row_owners)[row];
}
(*row_owners)[row] = p;
}

View File

@ -294,6 +294,8 @@ void POLY_BLOCK::fill(ScrollView* window, ScrollView::Color colour) {
}
}
}
delete lines;
}
#endif

View File

@ -139,6 +139,7 @@ bool TessdataManager::CombineDataFiles(
if (fseek(output_file,
sizeof(inT32) + sizeof(inT64) * TESSDATA_NUM_ENTRIES, SEEK_SET)) {
tprintf("Error seeking %s\n", output_filename);
fclose(output_file);
return false;
}

View File

@ -907,8 +907,10 @@ void Classify::AdaptToChar(TBLOB* Blob, CLASS_ID ClassId, int FontinfoId,
IClass = ClassForClassId(adaptive_templates->Templates, ClassId);
NumFeatures = GetAdaptiveFeatures(Blob, IntFeatures, &FloatFeatures);
if (NumFeatures <= 0)
if (NumFeatures <= 0) {
FreeFeatureSet(FloatFeatures);
return;
}
// Only match configs with the matching font.
BIT_VECTOR MatchingFontConfigs = NewBitVector(MAX_NUM_PROTOS);
@ -1001,6 +1003,8 @@ void Classify::DisplayAdaptedChar(TBLOB* blob, INT_CLASS_STRUCT* int_class) {
6 | 0x19, matcher_debug_separate_windows);
UpdateMatchDisplay();
}
delete sample;
#endif
}

View File

@ -877,6 +877,7 @@ void MasterTrainer::ReplaceFragmentedSamples() {
if (good_ch != INVALID_UNICHAR_ID)
good_junk[good_ch] = true; // We want this one.
}
delete frag;
}
#endif
// For now just use all the junk that was from natural fragments.
@ -891,6 +892,7 @@ void MasterTrainer::ReplaceFragmentedSamples() {
junk_samples_.extract_sample(s);
samples_.AddSample(frag_set.id_to_unichar(junk_id), sample);
}
delete frag;
}
junk_samples_.DeleteDeadSamples();
junk_samples_.OrganizeByFontAndClass();

View File

@ -118,6 +118,9 @@ void SVSync::StartProcess(const char* executable, const char* args) {
}
argv[argc] = NULL;
execvp(executable, argv);
free(argv[0]);
free(argv[1]);
delete[] argv;
}
#endif
}
@ -419,6 +422,7 @@ SVNetwork::SVNetwork(const char* hostname, int port) {
// Wait for server to show up.
// Note: There is no exception handling in case the server never turns up.
Close();
stream_ = socket(addr_info->ai_family, addr_info->ai_socktype,
addr_info->ai_protocol);
@ -431,6 +435,7 @@ SVNetwork::SVNetwork(const char* hostname, int port) {
sleep(1);
#endif
Close();
stream_ = socket(addr_info->ai_family, addr_info->ai_socktype,
addr_info->ai_protocol);
}