decode: avoid leaks on failure in ff_get_buffer()

Message ID 20170726213423.229F45DABE@aruru.libav.org
State New
Headers show

Commit Message

Janne Grunau July 26, 2017, 9:34 p.m.
Module: libav
Branch: master
Commit: de77671438c24ffea93398c8dc885d4dd04477de

Author:    Anton Khirnov <anton@khirnov.net>
Committer: Anton Khirnov <anton@khirnov.net>
Date:      Sat Jul  1 11:32:56 2017 +0200

decode: avoid leaks on failure in ff_get_buffer()

If the get_buffer() call fails, the frame might have some side data
already set. Make sure it gets freed.

CC: libav-stable@libav.org

---

 libavcodec/decode.c | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 9644e89..f7cd7f6 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1069,6 +1069,9 @@  end:
         frame->height = avctx->height;
     }
 
+    if (ret < 0)
+        av_frame_unref(frame);
+
     return ret;
 }