From e8813346e545ae1423b43658a116ae0949b4087c Mon Sep 17 00:00:00 2001 From: rfm Date: Mon, 4 Mar 2024 10:49:58 +0000 Subject: [PATCH] more leak fixes --- Source/NSJSONSerialization.m | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Source/NSJSONSerialization.m b/Source/NSJSONSerialization.m index 6fbc4a545..6cc9c3e1f 100644 --- a/Source/NSJSONSerialization.m +++ b/Source/NSJSONSerialization.m @@ -474,15 +474,18 @@ parseString(ParserState *state) { val = [NSMutableString new]; } + // Consume the trailing " + consumeChar(state); if (!state->mutableStrings) { if (NO == [val makeImmutable]) { - val = [val copy]; + NSString *str = [val copy]; + + RELEASE(val); + return str; } } - // Consume the trailing " - consumeChar(state); return val; } @@ -549,10 +552,9 @@ parseNumber(ParserState *state) if (number != numberBuffer) { free(number); - number = numberBuffer; } - parseError(state); - return nil; + parseError(state); + return nil; } BUFFER(c); while (isdigit(c = consumeChar(state))) @@ -1072,7 +1074,9 @@ writeObject(id obj, NSMutableString *output, NSInteger tabs) { if (NULL != error) { - NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys: + NSDictionary *userInfo; + + userInfo = [NSDictionary dictionaryWithObjectsAndKeys: _(@"JSON writing error"), NSLocalizedDescriptionKey, nil]; *error = [NSError errorWithDomain: NSCocoaErrorDomain