Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Fixed over-release of JSON string
Browse files Browse the repository at this point in the history
Local variable json was replaced by an autoreleased string, then
explicitly released, causing a crash when the main autorelease pool
drained.
  • Loading branch information
ericrwolfe committed Aug 7, 2011
1 parent 1753a13 commit 7c75395
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/extThree20JSON/Source/TTURLJSONResponse.m
Expand Up @@ -62,12 +62,11 @@ - (NSError*)request:(TTURLRequest*)request processResponse:(NSHTTPURLResponse*)r
NSError* err = nil;
if ([data isKindOfClass:[NSData class]]) {
#ifdef EXTJSON_SBJSON
NSString* json = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString* json = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
// When there are newline characters in the JSON string,
// the error "Unescaped control character '0x9'" will be thrown. This removes those characters.
json = [json stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
_rootObject = [[json JSONValue] retain];
TT_RELEASE_SAFELY(json);
if (!_rootObject) {
err = [NSError errorWithDomain:kTTExtJSONErrorDomain
code:kTTExtJSONErrorCodeInvalidJSON
Expand Down

0 comments on commit 7c75395

Please sign in to comment.