forked from zxing-cpp/zxing-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ios: add ASCII fallback if SetNSError encounters invalid UTF8 error s…
…tring This adds a layer of security to prevent nil crashes in case there are more cases with invalid UTF8 error messages. This supersedes zxing-cpp#717.
- Loading branch information
Showing
1 changed file
with
3 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,9 @@ void SetNSError(NSError *__autoreleasing _Nullable* error, | |
} | ||
NSString *errorDescription = @"Unknown C++ error"; | ||
if (message && strlen(message) > 0) { | ||
try { | ||
errorDescription = [NSString stringWithUTF8String: message]; | ||
} catch (NSException *exception) { | ||
errorDescription = @"Unknown ObjC error"; | ||
errorDescription = [NSString stringWithUTF8String: message]; | ||
if (errorDescription == nil) { | ||
[NSString stringWithCString: message encoding: NSASCIIStringEncoding]; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
axxel
Author
Owner
|
||
} | ||
} | ||
NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: errorDescription }; | ||
|
@axxel Well, I think this should be assigned to
errorDescription
😉