Skip to content

Commit

Permalink
Fix CID 1340271, 1340272, 1340273, 1340274 (Use after free)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jul 1, 2018
1 parent 52b44c5 commit abbd78a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ccmain/control.cpp
Expand Up @@ -1210,6 +1210,7 @@ float Tesseract::ClassifyBlobPlusOutlines(
C_BLOB* blob, STRING* best_str) {
C_OUTLINE_IT ol_it;
C_OUTLINE* first_to_keep = nullptr;
C_BLOB* local_blob = nullptr;
if (blob != nullptr) {
// Add the required outlines to the blob.
ol_it.set_to_list(blob->out_list());
Expand All @@ -1219,7 +1220,8 @@ float Tesseract::ClassifyBlobPlusOutlines(
if (ok_outlines[i]) {
// This outline is to be added.
if (blob == nullptr) {
blob = new C_BLOB(outlines[i]);
local_blob = new C_BLOB(outlines[i]);
blob = local_blob;
ol_it.set_to_list(blob->out_list());
} else {
ol_it.add_before_stay_put(outlines[i]);
Expand All @@ -1232,7 +1234,7 @@ float Tesseract::ClassifyBlobPlusOutlines(
if (first_to_keep == nullptr) {
// We created blob. Empty its outlines and delete it.
for (; !ol_it.empty(); ol_it.forward()) ol_it.extract();
delete blob;
delete local_blob;
cert = -c2;
} else {
// Remove the outlines that we put in.
Expand Down

0 comments on commit abbd78a

Please sign in to comment.