* Source/NSJSONSerialization.m: (parseString): allocate string also in case
it is empty.
* Tests/base/NSJSONSerialization/json.m: (main): add a couple of test cases
for commonly seen empty content; by the way adding some whitespace
diversity.
diff --git a/Source/NSJSONSerialization.m b/Source/NSJSONSerialization.m
index cb2ac8b..6d50d9b 100644
--- a/Source/NSJSONSerialization.m
+++ b/Source/NSJSONSerialization.m
@@ -367,6 +367,10 @@ parseString(ParserState *state)
[str release];
}
}
+ else if (nil == val)
+ {
+ val = [[NSMutableString alloc] init];
+ }
if (!state->mutableStrings)
{
val = [val makeImmutableCopyOnFail: YES];
diff --git a/Tests/base/NSJSONSerialization/json.m
b/Tests/base/NSJSONSerialization/json.m
index 39afa47..d7ec1fb 100644
--- a/Tests/base/NSJSONSerialization/json.m
+++ b/Tests/base/NSJSONSerialization/json.m
@@ -19,6 +19,7 @@ int main(void)
\"Width\": \"100\"\
},\
},\
+ \"emptyString\":\"\",\"emptyArray\":[],\"emptyObject\":{},\
\"IDs\": [116, 943, 234, 38793],\
\"escapeTest\": \"\\\"\\u0001\"\
}";
--
Lubomir Rintel (GoodData)
ext.: #7715
_______________________________________________
Bug-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-gnustep