OSDN Git Service

qsvdec: fix a memleak of async_fifo
authorAnton Khirnov <anton@khirnov.net>
Tue, 21 Jul 2015 17:41:59 +0000 (19:41 +0200)
committerAnton Khirnov <anton@khirnov.net>
Sat, 25 Jul 2015 15:23:46 +0000 (17:23 +0200)
init() is called whenever format changes, so current code would leak the
fifo in this case.

libavcodec/qsvdec.c

index 489375c..ef781d9 100644 (file)
@@ -73,10 +73,12 @@ int ff_qsv_decode_init(AVCodecContext *avctx, QSVContext *q, mfxSession session)
     mfxVideoParam param = { { 0 } };
     int ret;
 
-    q->async_fifo = av_fifo_alloc((1 + q->async_depth) *
-                                  (sizeof(mfxSyncPoint) + sizeof(QSVFrame*)));
-    if (!q->async_fifo)
-        return AVERROR(ENOMEM);
+    if (!q->async_fifo) {
+        q->async_fifo = av_fifo_alloc((1 + q->async_depth) *
+                                      (sizeof(mfxSyncPoint) + sizeof(QSVFrame*)));
+        if (!q->async_fifo)
+            return AVERROR(ENOMEM);
+    }
 
     ret = qsv_init_session(avctx, q, session);
     if (ret < 0) {