From 310e6009ca84c20b60f80127969cd50decdd1dbb Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 21 Sep 2021 14:44:22 +0200 Subject: [PATCH] libcamera: fix a segfault caused by queueing no longer valid requests The requests_ vector contains the requests created for a camera on start() but the vector elements are not removed on camera stop(). This leads to a segfault, when these requests that are no longer valid are queued again. Also move the streamName_ map clear to LibCamera::stop() where it should be, since its elements are added in the LibCamera::start() function. --- spa/plugins/libcamera/libcamera_wrapper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spa/plugins/libcamera/libcamera_wrapper.cpp b/spa/plugins/libcamera/libcamera_wrapper.cpp index dfc224812..6fc741d37 100644 --- a/spa/plugins/libcamera/libcamera_wrapper.cpp +++ b/spa/plugins/libcamera/libcamera_wrapper.cpp @@ -486,7 +486,6 @@ extern "C" { } int LibCamera::start() { - this->streamName_.clear(); for (unsigned int index = 0; index < this->config_->size(); ++index) { StreamConfiguration &cfg = this->config_->at(index); this->streamName_[cfg.stream()] = "stream" + std::to_string(index); @@ -536,6 +535,8 @@ extern "C" { } this->item_free_fn(); + this->requests_.clear(); + this->streamName_.clear(); } void LibCamera::close() {