Skip to content

Commit

Permalink
classify/mastertraining: Fix memory leaks
Browse files Browse the repository at this point in the history
Coverity report:

CID 1164739 (#1 of 1): Resource leak (RESOURCE_LEAK)
18. leaked_storage: Variable frag going out of scope leaks the storage it points to.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Oct 24, 2016
1 parent 963b935 commit 1327551
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions classify/mastertrainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();
Expand Down

0 comments on commit 1327551

Please sign in to comment.