Skip to content

Commit abbd78a

Browse files
committed
Fix CID 1340271, 1340272, 1340273, 1340274 (Use after free)
Signed-off-by: Stefan Weil <[email protected]>
1 parent 52b44c5 commit abbd78a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/ccmain/control.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,7 @@ float Tesseract::ClassifyBlobPlusOutlines(
12101210
C_BLOB* blob, STRING* best_str) {
12111211
C_OUTLINE_IT ol_it;
12121212
C_OUTLINE* first_to_keep = nullptr;
1213+
C_BLOB* local_blob = nullptr;
12131214
if (blob != nullptr) {
12141215
// Add the required outlines to the blob.
12151216
ol_it.set_to_list(blob->out_list());
@@ -1219,7 +1220,8 @@ float Tesseract::ClassifyBlobPlusOutlines(
12191220
if (ok_outlines[i]) {
12201221
// This outline is to be added.
12211222
if (blob == nullptr) {
1222-
blob = new C_BLOB(outlines[i]);
1223+
local_blob = new C_BLOB(outlines[i]);
1224+
blob = local_blob;
12231225
ol_it.set_to_list(blob->out_list());
12241226
} else {
12251227
ol_it.add_before_stay_put(outlines[i]);
@@ -1232,7 +1234,7 @@ float Tesseract::ClassifyBlobPlusOutlines(
12321234
if (first_to_keep == nullptr) {
12331235
// We created blob. Empty its outlines and delete it.
12341236
for (; !ol_it.empty(); ol_it.forward()) ol_it.extract();
1235-
delete blob;
1237+
delete local_blob;
12361238
cert = -c2;
12371239
} else {
12381240
// Remove the outlines that we put in.

0 commit comments

Comments
 (0)