From d32bdadda86b35c2960e4de877cf081b9d2dadb3 Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Mon, 5 Dec 2016 10:21:11 -0800
Subject: [PATCH] qsvdec: Fix memory leak on error

Bug-Id: CID 1396851
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
---
 libavcodec/qsvdec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index b6fead0b842..b83b0fcda82 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -306,8 +306,10 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
 
     do {
         ret = get_surface(avctx, q, &insurf);
-        if (ret < 0)
+        if (ret < 0) {
+            av_freep(&sync);
             return ret;
+        }
 
         ret = MFXVideoDECODE_DecodeFrameAsync(q->session, avpkt->size ? &bs : NULL,
                                               insurf, &outsurf, sync);
-- 
GitLab