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.
This commit is contained in:
Javier Martinez Canillas 2021-09-21 14:44:22 +02:00
parent 439dc8eb2a
commit 310e6009ca
No known key found for this signature in database
GPG key ID: C751E590D63F3D69

View file

@ -486,7 +486,6 @@ extern "C" {
} }
int LibCamera::start() { int LibCamera::start() {
this->streamName_.clear();
for (unsigned int index = 0; index < this->config_->size(); ++index) { for (unsigned int index = 0; index < this->config_->size(); ++index) {
StreamConfiguration &cfg = this->config_->at(index); StreamConfiguration &cfg = this->config_->at(index);
this->streamName_[cfg.stream()] = "stream" + std::to_string(index); this->streamName_[cfg.stream()] = "stream" + std::to_string(index);
@ -536,6 +535,8 @@ extern "C" {
} }
this->item_free_fn(); this->item_free_fn();
this->requests_.clear();
this->streamName_.clear();
} }
void LibCamera::close() { void LibCamera::close() {