Skip to content

Commit 60a0b3d

Browse files
atdrendeldmsnell
authored andcommitted
Objective-C: Fix memory leak in Patch (google/diff-match-patch#156)
Resolves google/diff-match-patch#156. The NSMutableArray being assigned to Patch.diffs isn't being autoreleased correctly. Since it's being assigned to a synthesized property marked with retain, and the NSMutableArray is being initialized with alloc-init, the array needs to be autoreleased so that it doesn't leak. See also Simperium/simperium-ios#89 Authored-by: Anthony Drendel <atdrendel@users.noreply.github.com>
1 parent 634e10f commit 60a0b3d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

objectivec/DiffMatchPatch.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ - (id)copyWithZone:(NSZone *)zone
189189
{
190190
Patch *newPatch = [[[self class] allocWithZone:zone] init];
191191

192-
newPatch.diffs = [[NSMutableArray alloc] initWithArray:self.diffs copyItems:YES];
192+
newPatch.diffs = [[[NSMutableArray alloc] initWithArray:self.diffs copyItems:YES] autorelease];
193193
newPatch.start1 = self.start1;
194194
newPatch.start2 = self.start2;
195195
newPatch.length1 = self.length1;

0 commit comments

Comments
 (0)