more leak fixes

This commit is contained in:
rfm 2024-03-04 10:49:58 +00:00
parent 619f902e9b
commit e8813346e5

View file

@ -474,15 +474,18 @@ parseString(ParserState *state)
{ {
val = [NSMutableString new]; val = [NSMutableString new];
} }
// Consume the trailing "
consumeChar(state);
if (!state->mutableStrings) if (!state->mutableStrings)
{ {
if (NO == [val makeImmutable]) if (NO == [val makeImmutable])
{ {
val = [val copy]; NSString *str = [val copy];
RELEASE(val);
return str;
} }
} }
// Consume the trailing "
consumeChar(state);
return val; return val;
} }
@ -549,10 +552,9 @@ parseNumber(ParserState *state)
if (number != numberBuffer) if (number != numberBuffer)
{ {
free(number); free(number);
number = numberBuffer;
} }
parseError(state); parseError(state);
return nil; return nil;
} }
BUFFER(c); BUFFER(c);
while (isdigit(c = consumeChar(state))) while (isdigit(c = consumeChar(state)))
@ -1072,7 +1074,9 @@ writeObject(id obj, NSMutableString *output, NSInteger tabs)
{ {
if (NULL != error) if (NULL != error)
{ {
NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys: NSDictionary *userInfo;
userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
_(@"JSON writing error"), NSLocalizedDescriptionKey, _(@"JSON writing error"), NSLocalizedDescriptionKey,
nil]; nil];
*error = [NSError errorWithDomain: NSCocoaErrorDomain *error = [NSError errorWithDomain: NSCocoaErrorDomain