mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Fix leaks
This commit is contained in:
parent
77c66e3d95
commit
088b76bed1
10 changed files with 71 additions and 65 deletions
|
@ -23,6 +23,8 @@ implementations of the NSString methods in NSString itself.
|
|||
length: (NSUInteger)l
|
||||
encoding: (NSStringEncoding)encoding
|
||||
{
|
||||
if (characters) free(characters);
|
||||
characters = NULL;
|
||||
if (l > 0)
|
||||
{
|
||||
if (encoding == NSUnicodeStringEncoding)
|
||||
|
@ -37,7 +39,7 @@ implementations of the NSString methods in NSString itself.
|
|||
s = [[NSString alloc] initWithBytes: c
|
||||
length: l
|
||||
encoding: encoding];
|
||||
if (s == nil) return nil;
|
||||
if (s == nil) {RELEASE(self); return nil;}
|
||||
l = [s length] * sizeof(unichar);
|
||||
characters = malloc(l);
|
||||
[s getCharacters: characters];
|
||||
|
@ -53,6 +55,8 @@ implementations of the NSString methods in NSString itself.
|
|||
encoding: (NSStringEncoding)encoding
|
||||
freeWhenDone: (BOOL)freeWhenDone
|
||||
{
|
||||
if (characters) free(characters);
|
||||
characters = NULL;
|
||||
if (l > 0)
|
||||
{
|
||||
if (encoding == NSUnicodeStringEncoding)
|
||||
|
@ -68,7 +72,7 @@ implementations of the NSString methods in NSString itself.
|
|||
length: l
|
||||
encoding: encoding
|
||||
freeWhenDone: freeWhenDone];
|
||||
if (s == nil) return nil;
|
||||
if (s == nil) {RELEASE(self); return nil;}
|
||||
l = [s length] * sizeof(unichar);
|
||||
characters = malloc(l);
|
||||
[s getCharacters: characters];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue