diff options
author | Damiano Galassi <[email protected]> | 2018-04-15 09:07:21 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2018-04-15 09:07:21 +0200 |
commit | c4ab876310f5e8f7c4a3d7c75cc4bccd4030e525 (patch) | |
tree | fdba44f22ed1709e52b16076ec69e05e37a7afa2 /macosx/NSJSONSerialization+HBAdditions.m | |
parent | a8a3248bc0894e33fd548565d2d67bd6ce564c35 (diff) |
MacGui: do not crash if the presets file is not a valid utf8 file.
Diffstat (limited to 'macosx/NSJSONSerialization+HBAdditions.m')
-rw-r--r-- | macosx/NSJSONSerialization+HBAdditions.m | 3 |
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; |