Skip to content

Commit

Permalink
ileak fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Mar 4, 2024
1 parent cd2626e commit 619f902
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2024-03-04 Richard Frith-Macdonald <[email protected]>

* Source/NSJSONSerialization.m: Fix leak reported by Larry Campbell
git issue #377

2024-02-20 Richard Frith-Macdonald <[email protected]>

* Source/NSUserDefaults.m: Move posting of notification outside lock
Expand Down
7 changes: 4 additions & 3 deletions Source/NSJSONSerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,9 @@
n = [stream read: &bytes[1] maxLength: i];
if (n == i)
{
str = [[NSString alloc] initWithUTF8String: (char*)bytes];
str = [NSString stringWithUTF8String: (char*)bytes];
[str getCharacters: state->buffer
range: NSMakeRange(0,1)];
[str release];
}
else
{
Expand Down Expand Up @@ -278,6 +277,7 @@
state->source = str;
updateStringBuffer(state);
state->source = stream;
RELEASE(str);
}

/**
Expand Down Expand Up @@ -1146,11 +1146,12 @@ + (id) JSONObjectWithStream: (NSInputStream *)stream
obj = parseValue(&p);
// Consume any data in the stream that we've failed to read
updateStreamBuffer(&p);
RELEASE(p.source);
if (NULL != error)
{
*error = p.error;
}
return [obj autorelease];
return AUTORELEASE(obj);
}

+ (NSInteger) writeJSONObject: (id)obj
Expand Down

0 comments on commit 619f902

Please sign in to comment.