From d1007485e4eeaf1f1c800ff954537ea6fe5cdcea Mon Sep 17 00:00:00 2001 From: Hirokazu Honda Date: Wed, 1 Sep 2021 03:37:39 +0900 Subject: android: camera_device: Fix crash in calling CameraDevice::close() The problem is happening because we seem to add a CameraStream associated buffer (depending on the CameraStream::Type) to the Request, in CameraDevice::processCaptureRequest(). However, when the camera stops, all the current buffers are marked with FrameMetadata::FrameCancelled and proceed to completion. But the buffer associated with the CameraStream (that was previously added to the request) has now been cleared out with a part of streams_.clear(), even before the camera stop() has been invoked. Any access to those request buffers after they have been cleared, will result in a crash. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain Reviewed-by: Jacopo Mondi Signed-off-by: Kieran Bingham --- src/android/camera_device.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/android') diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index ef4fbab8..90186710 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -424,8 +424,6 @@ int CameraDevice::open(const hw_module_t *hardwareModule) void CameraDevice::close() { - streams_.clear(); - stop(); camera_->release(); @@ -458,6 +456,7 @@ void CameraDevice::stop() camera_->stop(); descriptors_ = {}; + streams_.clear(); state_ = State::Stopped; } -- cgit v1.2.1