From e8cc0a26583ce6fa3d25fd10173a037f2c5e57c8 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Wed, 20 May 2020 17:04:59 +0200 Subject: libcamera: raspberry: Fix segfault in ~RPiCameraData() The RPiCameraData class destructor tries to stop its ipa_ instance without making sure it has been initialized. If the RPiCameraData gets destroyed before its ipa_ member is initialized, for example if the sensor initialization fails during the match() function, a nullptr dereference segfault is triggered preventing a graceful library teardown. Fix this by checking for ipa_ to be initialized before stopping it. Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libcamera/pipeline/raspberrypi') diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 07ca9f5d..e16a9c7f 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -304,7 +304,8 @@ public: } /* Stop the IPA proxy thread. */ - ipa_->stop(); + if (ipa_) + ipa_->stop(); } void frameStarted(uint32_t sequence); -- cgit v1.2.1