Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Commit 28e5e59

Browse files
committed
Fix crash in Objective C
Bug (internal to Google): b/124992541
1 parent 895a951 commit 28e5e59

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

objectivec/DiffMatchPatch.m

+4-2
Original file line numberDiff line numberDiff line change
@@ -1598,8 +1598,8 @@ - (void)diff_cleanupSemantic:(NSMutableArray *)diffs;
15981598
thisPointer = 1;
15991599
while (thisPointer < diffs.count) {
16001600
if (prevDiff.operation == DIFF_DELETE && thisDiff.operation == DIFF_INSERT) {
1601-
NSString *deletion = prevDiff.text;
1602-
NSString *insertion = thisDiff.text;
1601+
NSString *deletion = [prevDiff.text copy];
1602+
NSString *insertion = [thisDiff.text copy];
16031603
NSUInteger overlap_length1 = (NSUInteger)diff_commonOverlap((CFStringRef)deletion, (CFStringRef)insertion);
16041604
NSUInteger overlap_length2 = (NSUInteger)diff_commonOverlap((CFStringRef)insertion, (CFStringRef)deletion);
16051605
if (overlap_length1 >= overlap_length2) {
@@ -1629,6 +1629,8 @@ - (void)diff_cleanupSemantic:(NSMutableArray *)diffs;
16291629
thisPointer++;
16301630
}
16311631
}
1632+
[deletion release];
1633+
[insertion release];
16321634
thisPointer++;
16331635
}
16341636
thisPointer++;

0 commit comments

Comments
 (0)