From 50d24d99ea87ae75a93e84d850e0e90c951198dc Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 25 Sep 2017 18:13:14 +0200 Subject: [PATCH] MediaPickerViewController: Add sanity checks to avoid crashes - [MediaPickerViewController setupAVCapture] (in Riot) (MediaPickerViewController.m:1158) (https://github.com/matrix-org/riot-ios-rageshakes/issues/312) - [MediaPickerViewController tearDownAVCapture] (in Riot) (MediaPickerViewController.m:1198) (https://github.com/matrix-org/riot-ios-rageshakes/issues/314) --- Riot/ViewController/MediaPickerViewController.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Riot/ViewController/MediaPickerViewController.m b/Riot/ViewController/MediaPickerViewController.m index 0002f8960..262ecd1c0 100644 --- a/Riot/ViewController/MediaPickerViewController.m +++ b/Riot/ViewController/MediaPickerViewController.m @@ -1000,6 +1000,12 @@ static void *RecordingContext = &RecordingContext; NSLog(@"[MediaPickerVC] Attemping to setup AVCapture when it is already started!"); return; } + if (!cameraQueue) + { + NSLog(@"[MediaPickerVC] Attemping to setup AVCapture when it is being destroyed!"); + return; + } + isCaptureSessionSetupInProgress = YES; [self.cameraActivityIndicator startAnimating]; @@ -1192,6 +1198,12 @@ static void *RecordingContext = &RecordingContext; - (void)tearDownAVCapture { + if (!cameraQueue) + { + NSLog(@"[MediaPickerVC] Attemping to tear down AVCapture when it is being destroyed!"); + return; + } + dispatch_sync(cameraQueue, ^{ frontCameraInput = nil; backCameraInput = nil;