Fix more leaks

This commit is contained in:
rfm 2024-11-17 13:32:31 +00:00
parent 0fb9739f21
commit 7cff5fc106
4 changed files with 21 additions and 8 deletions

View file

@ -24,6 +24,7 @@
#import "common.h"
#import "GSPrivate.h"
#import "GNUstepBase/GSLocale.h"
#import "Foundation/NSAutoreleasePool.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSArray.h"
#import "Foundation/NSLock.h"
@ -262,6 +263,7 @@ GSLanguageFromLocale(NSString *locale)
|| [locale length] < 2)
return @"English";
ENTER_POOL
gbundle = [NSBundle bundleForLibrary: @"gnustep-base"];
aliases = [gbundle pathForResource: @"Locale"
ofType: @"aliases"
@ -271,22 +273,27 @@ GSLanguageFromLocale(NSString *locale)
NSDictionary *dict;
dict = [NSDictionary dictionaryWithContentsOfFile: aliases];
language = [dict objectForKey: locale];
language = [[dict objectForKey: locale] copy];
if (language == nil && [locale pathExtension] != nil)
{
locale = [locale stringByDeletingPathExtension];
if ([locale isEqual: @"C"] || [locale isEqual: @"POSIX"])
return @"English";
language = [dict objectForKey: locale];
{
language = @"English";
}
else
{
language = [[dict objectForKey: locale] copy];
}
}
if (language == nil)
{
locale = [locale substringWithRange: NSMakeRange(0, 2)];
language = [dict objectForKey: locale];
language = [[dict objectForKey: locale] copy];
}
}
return language;
LEAVE_POOL
return AUTORELEASE(language);
}
NSArray *

View file

@ -74,6 +74,8 @@ int main()
PASS_RUNS([node setRootElement: nil], "setting a nil root is ignored");
PASS_EQUAL([node rootElement], elem, "root element remains");
DESTROY(elem);
DESTROY(node);
node = [[NSXMLDocument alloc] initWithXMLString:documentXML
options:0
error:NULL];
@ -96,6 +98,8 @@ int main()
error:NULL];
PASS([node isEqual: node2],
"Equal documents are equivalent");
RELEASE(node2);
RELEASE(node);
#endif
END_SET("NSXMLDocument")

View file

@ -10,10 +10,12 @@ int main()
parser = [c new];
test_alloc(@"GSSloppyXMLParser");
test_NSObject(@"GSSloppyXMLParser", [NSArray arrayWithObject: parser]);
DESTROY(parser);
parser = [NSXMLParser new];
test_alloc(@"NSXMLParser");
test_NSObject(@"NSXMLParser", [NSArray arrayWithObject: parser]);
DESTROY(parser);
[arp release]; arp = nil;

View file

@ -289,7 +289,7 @@ testParseData(NSData *xml, NSString *expect, BOOL strict)
if (Nil == c) c = [NSXMLParser class];
parser = [[c alloc] initWithData: xml];
result = testParser(parser, expect);
RELEASE(parser);
[arp release];
return result;
}
@ -315,7 +315,7 @@ testParseStream(NSInputStream *stream, NSString *expect, BOOL strict)
if (Nil == c) c = [NSXMLParser class];
parser = [[c alloc] initWithStream: stream];
result = testParser(parser, expect);
RELEASE(parser);
[arp release];
return result;
}