From dee99d47267e9d9204884b2ff798cd02eb5914f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Wed, 29 Apr 2020 14:40:35 +0200 Subject: qcam: Check that camera can generate configuration from roles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the camera can not generate a configuration from the requested roles it returns a nullptr which leads to a nullptr dereference. Fix this by adding a check that the camera generated a configuration before trying to access it. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/qcam/main_window.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 74427592..b9348111 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -296,6 +296,10 @@ int MainWindow::startCapture() /* Configure the camera. */ config_ = camera_->generateConfiguration(roles); + if (!config_) { + qWarning() << "Failed to generate configuration from roles"; + return -EINVAL; + } StreamConfiguration &cfg = config_->at(0); -- cgit v1.2.1