Fixes possible crash if url is malicious

Try scan a QR code with content `ss://sdf invalid`, an uncaught
exception raises.
This commit is contained in:
Timothy Qiu
2017-08-01 19:39:46 +08:00
parent f1db8fff41
commit b1e95babaa

View File

@ -56,7 +56,10 @@ void ScanQRCodeOnScreen() {
NSLog(@"%@", feature.messageString); NSLog(@"%@", feature.messageString);
if ( [feature.messageString hasPrefix:@"ss://"] ) if ( [feature.messageString hasPrefix:@"ss://"] )
{ {
[foundSSUrls addObject:[NSURL URLWithString:feature.messageString]]; NSURL *url = [NSURL URLWithString:feature.messageString];
if (url) {
[foundSSUrls addObject:url];
}
} }
} }
CGImageRelease(image); CGImageRelease(image);