From 1c438e1fac45b9f0a7dedfd19ae5d9754e3a4d1c Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Wed, 4 Jul 2012 23:32:34 -0500 Subject: [PATCH] Fix leaks. --- Cocoa/Plug-Ins/Hex Editor/HexTextView.m | 5 +++-- Cocoa/Plug-Ins/Hex Editor/HexWindowController.mm | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cocoa/Plug-Ins/Hex Editor/HexTextView.m b/Cocoa/Plug-Ins/Hex Editor/HexTextView.m index 267fb3c..2e6f95a 100644 --- a/Cocoa/Plug-Ins/Hex Editor/HexTextView.m +++ b/Cocoa/Plug-Ins/Hex Editor/HexTextView.m @@ -77,6 +77,7 @@ if(*((unsigned short *)[unicodeData mutableBytes]) == 0xFEFF || *((unsigned short *)[unicodeData mutableBytes]) == 0xFFFE) [unicodeData replaceBytesInRange:NSMakeRange(0,2) withBytes:NULL length:0]; [self editData:[[[self window] windowController] data] replaceBytesInRange:selection withData:unicodeData]; + [unicodeData release]; } } @@ -213,7 +214,7 @@ static NSRange draggedRange; - (void)insertText:(NSString *)string { NSRange selection = [(HexEditorDelegate *)[self delegate] rangeForUserTextChange]; - NSMutableData *data = [[[[self window] windowController] data] mutableCopy]; + NSMutableData *data = [[[[[self window] windowController] data] mutableCopy] autorelease]; NSData *replaceData = [string dataUsingEncoding:NSASCIIStringEncoding]; if(self == (id) [(HexEditorDelegate *)[self delegate] hex]) @@ -252,7 +253,6 @@ static NSRange draggedRange; // replace bytes (updates views implicitly, records an undo) [self editData:data replaceBytesInRange:selection withData:replaceData]; - [data release]; // set the new selection (insertion point) selection.location++; @@ -357,6 +357,7 @@ static NSRange draggedRange; // record undo with new data object [[[[self window] undoManager] prepareWithInvocationTarget:self] editData:newData replaceBytesInRange:newRange withData:oldBytes]; + [oldBytes release]; [[[self window] undoManager] setActionName:NSLocalizedString(@"Typing", nil)]; if(closeUndoGroup) [[[self window] undoManager] endUndoGrouping]; diff --git a/Cocoa/Plug-Ins/Hex Editor/HexWindowController.mm b/Cocoa/Plug-Ins/Hex Editor/HexWindowController.mm index daa669d..720b84f 100644 --- a/Cocoa/Plug-Ins/Hex Editor/HexWindowController.mm +++ b/Cocoa/Plug-Ins/Hex Editor/HexWindowController.mm @@ -169,12 +169,12 @@ OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource) - (void)saveResource:(id)sender { - [backup setData:[[resource data] copy]]; + [backup setData:[[[resource data] copy] autorelease]]; } - (void)revertResource:(id)sender { - [resource setData:[[backup data] copy]]; + [resource setData:[[[backup data] copy] autorelease]]; } - (void)showFind:(id)sender @@ -210,7 +210,7 @@ OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource) else { // this should refresh the view automatically - [resource setData:[[object data] copy]]; + [resource setData:[[[object data] copy]] autorelease]; [self setDocumentEdited:NO]; } } @@ -230,6 +230,7 @@ OSStatus Plug_InitInstance(Plug_PlugInRef plug, Plug_ResourceRef resource) NSMutableParagraphStyle *paragraph = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; [paragraph setLineBreakMode:NSLineBreakByCharWrapping]; NSDictionary *dictionary = [NSDictionary dictionaryWithObject:paragraph forKey:NSParagraphStyleAttributeName]; + [paragraph release]; // do stuff with data [offset setString:[hexDelegate offsetRepresentation:data]];