From 2f1b6e455d540b81f93cb24f2197df1490e0f280 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Thu, 1 Oct 1998 16:07:02 +0000 Subject: [PATCH] Fixed memory leak git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3011 72102866-910b-0410-8b05-ffd578937521 --- Source/NSDictionary.m | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m index 09e079390..5d2f2a6cc 100644 --- a/Source/NSDictionary.m +++ b/Source/NSDictionary.m @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -40,6 +39,9 @@ @implementation NSDictionary +@class NSGDictionary; +@class NSGMutableDictionary; + static Class NSDictionary_concrete_class; static Class NSMutableDictionary_concrete_class; @@ -225,6 +227,7 @@ static Class NSMutableDictionary_concrete_class; OBJC_MALLOC (keys, id, capacity); if (firstObject != nil) { + NSDictionary *d; objects[num_pairs] = firstObject; /* Keep grabbing arguments until we get a nil... */ while ((arg = va_arg (ap, id))) @@ -246,9 +249,11 @@ static Class NSMutableDictionary_concrete_class; } } NSAssert (argi % 2 == 0, NSInvalidArgumentException); - return [[[self alloc] initWithObjects: objects forKeys: keys - count: num_pairs] - autorelease]; + d = [[[self alloc] initWithObjects: objects forKeys: keys + count: num_pairs] autorelease]; + OBJC_FREE(objects); + OBJC_FREE(keys); + return d; } /* FIRSTOBJECT was nil; just return an empty NSDictionary object. */ return [self dictionary];