From: Steinar H. Gunderson Date: Thu, 6 Dec 2018 16:55:57 +0000 (+0100) Subject: Fix some leaks in MJPEGEncoder. X-Git-Tag: 1.8.0~51 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=271ddbb0c7e84560e73e89b1a125576477f95380 Fix some leaks in MJPEGEncoder. --- diff --git a/nageru/mjpeg_encoder.cpp b/nageru/mjpeg_encoder.cpp index 614cb5c..07deae0 100644 --- a/nageru/mjpeg_encoder.cpp +++ b/nageru/mjpeg_encoder.cpp @@ -177,6 +177,11 @@ MJPEGEncoder::MJPEGEncoder(HTTPD *httpd, const string &va_display) running = true; } +MJPEGEncoder::~MJPEGEncoder() +{ + av_free(avctx->pb->buffer); +} + void MJPEGEncoder::stop() { if (!running) { @@ -268,7 +273,7 @@ void MJPEGEncoder::encoder_thread_func() unique_lock lock(mu); for (;;) { any_frames_to_be_encoded.wait(lock, [this] { return !frames_to_be_encoded.empty() || should_quit; }); - if (should_quit) return; + if (should_quit) break; QueuedFrame qf = move(frames_to_be_encoded.front()); frames_to_be_encoded.pop(); @@ -288,6 +293,11 @@ void MJPEGEncoder::encoder_thread_func() exit(1); } } + + free(tmp_y); + free(tmp_cbcr); + free(tmp_cb); + free(tmp_cr); } class VABufferDestroyer { diff --git a/nageru/mjpeg_encoder.h b/nageru/mjpeg_encoder.h index 3ce3439..f3c9d99 100644 --- a/nageru/mjpeg_encoder.h +++ b/nageru/mjpeg_encoder.h @@ -30,6 +30,7 @@ struct VectorDestinationManager; class MJPEGEncoder { public: MJPEGEncoder(HTTPD *httpd, const std::string &va_display); + ~MJPEGEncoder(); void stop(); void upload_frame(int64_t pts, unsigned card_index, RefCountedFrame frame, const bmusb::VideoFormat &video_format, size_t y_offset, size_t cbcr_offset);