From 7b260d4c9ce46f6dc5d845005f5a8a3600b541ba Mon Sep 17 00:00:00 2001
From: Anthony Drendel <atdrendel@users.noreply.github.com>
Date: Tue, 19 Mar 2024 23:31:24 +0100
Subject: [PATCH] Fix memory leak in Patch

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.
---
 objectivec/DiffMatchPatch.m | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/objectivec/DiffMatchPatch.m b/objectivec/DiffMatchPatch.m
index 580f2656..86c3d310 100755
--- a/objectivec/DiffMatchPatch.m
+++ b/objectivec/DiffMatchPatch.m
@@ -189,7 +189,7 @@ - (id)copyWithZone:(NSZone *)zone
 {
   Patch *newPatch = [[[self class] allocWithZone:zone] init];
 
-  newPatch.diffs = [[NSMutableArray alloc] initWithArray:self.diffs copyItems:YES];
+  newPatch.diffs = [[[NSMutableArray alloc] initWithArray:self.diffs copyItems:YES] autorelease];
   newPatch.start1 = self.start1;
   newPatch.start2 = self.start2;
   newPatch.length1 = self.length1;