[libcamera-devel] [RFC/PATCH 1/5] qcam: Check that camera can generate configuration from roles

Niklas Söderlund niklas.soderlund at ragnatech.se
Thu Apr 30 02:36:00 CEST 2020


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 <niklas.soderlund at ragnatech.se>
---
 src/qcam/main_window.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index ee779728fc630da8..b683c2e00d317307 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -293,6 +293,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);
 
-- 
2.26.0



More information about the libcamera-devel mailing list