]> git.sesse.net Git - nageru/commitdiff
Fix some leaks in MJPEGEncoder.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 6 Dec 2018 16:55:57 +0000 (17:55 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Thu, 6 Dec 2018 16:55:57 +0000 (17:55 +0100)
nageru/mjpeg_encoder.cpp
nageru/mjpeg_encoder.h

index 614cb5cc8836a80b3eb4831d91a1465c8cd4a73e..07deae02289a3c321a6a4c58c036a8c96109ccb8 100644 (file)
@@ -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<mutex> 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 {
index 3ce34396efa4253290efe66e1a59a2574ef757b8..f3c9d9946aec6b8e301f80b0583b072deffc459d 100644 (file)
@@ -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);