mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
fix for issue #365
This commit is contained in:
parent
75fd9549ef
commit
b7f66a9dd3
2 changed files with 32 additions and 12 deletions
|
@ -1,5 +1,9 @@
|
|||
2024-01-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSJSONSerialization.m: Fix for issue #365 ... don't try to
|
||||
create a string ending with the first half of a unicode surrogate pair.
|
||||
2024-01-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSNotificationCenter.m: fix for memory leak should keep the
|
||||
observer retained until removed.
|
||||
|
||||
|
|
|
@ -413,20 +413,36 @@ parseString(ParserState *state)
|
|||
buffer[bufferIndex++] = next;
|
||||
if (bufferIndex >= BUFFER_SIZE)
|
||||
{
|
||||
NSMutableString *str;
|
||||
NSMutableString *str;
|
||||
int len = bufferIndex;
|
||||
|
||||
str = [[NSMutableString alloc] initWithCharacters: buffer
|
||||
length: bufferIndex];
|
||||
bufferIndex = 0;
|
||||
if (nil == val)
|
||||
{
|
||||
val = str;
|
||||
}
|
||||
else
|
||||
{
|
||||
[val appendString: str];
|
||||
[str release];
|
||||
}
|
||||
if (next < 0xd800 || next > 0xdbff)
|
||||
{
|
||||
str = [[NSMutableString alloc] initWithCharacters: buffer
|
||||
length: len];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The most recent unicode character is the first half of a
|
||||
* surrogate pair, so we need to defer it to the next chunk
|
||||
* to make sure the whole unicode character is in the same
|
||||
* string (otherwise we would have an invalid string).
|
||||
*/
|
||||
len--;
|
||||
str = [[NSMutableString alloc] initWithCharacters: buffer
|
||||
length: len];
|
||||
buffer[bufferIndex++] = next;
|
||||
}
|
||||
if (nil == val)
|
||||
{
|
||||
val = str;
|
||||
}
|
||||
else
|
||||
{
|
||||
[val appendString: str];
|
||||
RELEASE(str);
|
||||
}
|
||||
}
|
||||
next = consumeChar(state);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue