From ec040f965054cc6cef33d4fa3f02daa250c50037 Mon Sep 17 00:00:00 2001 From: rfm Date: Tue, 26 May 2015 13:12:41 +0000 Subject: [PATCH] fix a few leaks git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38557 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSURLConnection.m | 1 + Source/NSXMLParser.m | 23 ++++++++++++++++------- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index cfb26938c..18feda82a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-05-26 Richard Frith-Macdonald + + * Source/NSURLConnection.m: Fix leak of limit date + * Source/NSXMLParser.m: Fix leak of string + 2015-05-26: Sebastian Reitenbach * Source/Additions/Unicode.m diff --git a/Source/NSURLConnection.m b/Source/NSURLConnection.m index 61f8dc880..c64fc8c2f 100644 --- a/Source/NSURLConnection.m +++ b/Source/NSURLConnection.m @@ -334,6 +334,7 @@ typedef struct { [loop runMode: NSDefaultRunLoopMode beforeDate: limit]; } + [limit release]; if (NO == [collector done]) { data = nil; diff --git a/Source/NSXMLParser.m b/Source/NSXMLParser.m index 2c92cc279..11c446022 100644 --- a/Source/NSXMLParser.m +++ b/Source/NSXMLParser.m @@ -734,7 +734,7 @@ static SEL foundIgnorableSel; RELEASE(this->tagPath); RELEASE(this->namespaces); RELEASE(this->defaults); - [this release]; + RELEASE(this); _parser = 0; _handler = 0; } @@ -782,7 +782,7 @@ static SEL foundIgnorableSel; tmp = [[NSString alloc] initWithData: data encoding: enc]; this->data = [[tmp dataUsingEncoding: NSUTF8StringEncoding] retain]; - [tmp release]; + RELEASE(tmp); } this->tagPath = [[NSMutableArray alloc] init]; this->namespaces = [[NSMutableArray alloc] init]; @@ -1587,6 +1587,7 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); seg = NewUTF8STR(start, ptr - start); if (nil == seg) { + [m release]; [self _parseError: @"invalid character in quoted string" code: NSXMLParserInvalidCharacterError]; return nil; @@ -2008,6 +2009,7 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); if (c != '>') { [attributes release]; + [tag release]; return [self _parseError: @"" code: NSXMLParserGTRequiredError]; } @@ -2024,6 +2026,8 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); c = cget(); if (c != '>') { + [attributes release]; + [tag release]; return [self _parseError: @"" code: NSXMLParserGTRequiredError]; @@ -2034,6 +2038,8 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); if ([tag isEqualToString: @"?xml"] && sp != [this->data bytes]) { + [attributes release]; + [tag release]; return [self _parseError: @"bad preamble" code: NSXMLParserDocumentStartError]; } @@ -2062,6 +2068,9 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); #endif if (!this->acceptHTML && [arg length] == 0) { + RELEASE(arg); + RELEASE(tag); + RELEASE(attributes); return [self _parseError: @"empty attribute name" code: NSXMLParserAttributeNotStartedError]; } @@ -2082,7 +2091,7 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); } val = [self _newQarg]; [attributes setObject: val forKey: arg]; - [val release]; + RELEASE(val); c = cget(); // get character behind qarg value while (isspace(c)) { @@ -2092,11 +2101,11 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); else // implicit { [attributes setObject: @"" forKey: arg]; - } - [arg release]; + } + RELEASE(arg); } - [attributes release]; - [tag release]; + RELEASE(attributes); + RELEASE(tag); vp = this->cp; // prepare for next value c = cget(); // skip > and fetch next character }