summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2018-04-15 09:07:21 +0200
committerDamiano Galassi <[email protected]>2018-04-15 09:07:21 +0200
commitc4ab876310f5e8f7c4a3d7c75cc4bccd4030e525 (patch)
treefdba44f22ed1709e52b16076ec69e05e37a7afa2
parenta8a3248bc0894e33fd548565d2d67bd6ce564c35 (diff)
MacGui: do not crash if the presets file is not a valid utf8 file.
-rw-r--r--macosx/NSJSONSerialization+HBAdditions.m3
1 files changed, 3 insertions, 0 deletions
diff --git a/macosx/NSJSONSerialization+HBAdditions.m b/macosx/NSJSONSerialization+HBAdditions.m
index 0f18eb17c..e7b981ce9 100644
--- a/macosx/NSJSONSerialization+HBAdditions.m
+++ b/macosx/NSJSONSerialization+HBAdditions.m
@@ -10,6 +10,9 @@
+ (id)HB_JSONObjectWithUTF8String:(const char *)nullTerminatedCString options:(NSJSONReadingOptions)opt error:(NSError **)error;
{
+ if (!nullTerminatedCString) {
+ return nil;
+ }
NSData *data = [NSData dataWithBytes:nullTerminatedCString length:strlen(nullTerminatedCString)];
id result = [NSJSONSerialization JSONObjectWithData:data options:opt error:error];
return result;