Skip to content

Commit 403ea49

Browse files
committed
Fix issues found in review
1 parent 0677f88 commit 403ea49

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/SubtitleOctopus.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,12 @@ class BoundingBox {
142142
min_y = MIN(min_y, other.min_y);
143143
max_x = MAX(max_x, other.max_x);
144144
max_y = MAX(max_y, other.max_y);
145-
other.min_x = other.max_x = other.min_y = other.max_y = -1;
146145
return true;
147146
}
147+
148+
void clear() {
149+
min_x = max_x = min_y = max_y = -1;
150+
}
148151
};
149152

150153
static int _is_move_tag_animated(char *begin, char *end) {
@@ -463,7 +466,10 @@ class SubtitleOctopus {
463466
if (boxes[box1].empty()) continue;
464467
for (int box2 = box1 + 1; box2 < MAX_BLEND_STORAGES; box2++) {
465468
if (boxes[box2].empty()) continue;
466-
if (boxes[box1].tryMerge(boxes[box2])) merged = true;
469+
if (boxes[box1].tryMerge(boxes[box2])) {
470+
boxes[box2].clear();
471+
merged = true;
472+
}
467473
}
468474
}
469475
if (!merged) break;
@@ -473,6 +479,7 @@ class SubtitleOctopus {
473479
for (int box = 0; box < MAX_BLEND_STORAGES; box++) {
474480
if (boxes[box].empty()) continue;
475481
RenderBlendPart *part = renderBlendPart(boxes[box], img);
482+
if (part == NULL) return NULL;
476483
part->next = m_blendResult.part;
477484
m_blendResult.part = part;
478485
}

0 commit comments

Comments
 (0)