libcamera: fixed a small leak and double free

This commit is contained in:
raghu447 2020-06-15 12:01:19 +05:30
parent 5778de090f
commit 7c05a7f7b4
3 changed files with 10 additions and 11 deletions

View file

@ -162,7 +162,6 @@ static int impl_clear(struct spa_handle *handle)
if(this->dev.camera) {
deleteLibCamera(this->dev.camera);
free(this->dev.camera);
this->dev.camera = NULL;
}
return 0;

View file

@ -900,7 +900,6 @@ static int impl_clear(struct spa_handle *handle)
if(port->dev.camera) {
deleteLibCamera(port->dev.camera);
free(port->dev.camera);
port->dev.camera = NULL;
}
if(this->have_source) {

View file

@ -529,6 +529,16 @@ extern "C" {
void LibCamera::stop() {
this->disconnect();
uint32_t bufIdx = 0;
StreamConfiguration &cfg = this->config_->at(0);
Stream *stream = cfg.stream();
for (const std::unique_ptr<FrameBuffer> &buffer : this->allocator_->buffers(stream)) {
delete [] this->fd_[bufIdx];
bufIdx++;
}
delete [] this->fd_;
spa_log_info(this->log_, "Stopping camera ...");
this->cam_->stop();
if(this->allocator_) {
@ -536,15 +546,6 @@ extern "C" {
this->allocator_ = nullptr;
}
if(this->fd_) {
for(uint32_t i = 0; i < this->nplanes_; i++) {
delete this->fd_[i];
this->fd_[i] = nullptr;
}
delete this->fd_;
this->fd_ = nullptr;
}
this->item_free_fn();
}