[FFmpeg-devel,2/5] decode: avoid leaks on failure in ff_get_buffer()

Submitted by wm4 on Oct. 13, 2017, 4:59 p.m.

Details

Message ID 20171013165919.7642-3-nfxjfg@googlemail.com
State New
Headers show

Commit Message

wm4 Oct. 13, 2017, 4:59 p.m.
From: Anton Khirnov <anton@khirnov.net>

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

Merges Libav commit de77671438c24ffea93398c8dc885d4dd04477de.
---
 libavcodec/decode.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

James Almer Oct. 30, 2017, 12:30 a.m.
On 10/13/2017 1:59 PM, wm4 wrote:
> From: Anton Khirnov <anton@khirnov.net>
> 
> 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
> 
> Merges Libav commit de77671438c24ffea93398c8dc885d4dd04477de.
> ---
>  libavcodec/decode.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index 1337ffb527..437b848248 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -1658,6 +1658,9 @@ end:
>          frame->height = avctx->height;
>      }
>  
> +    if (ret < 0)
> +        av_frame_unref(frame);
> +
>      return ret;
>  }

Applied as well.

Patch hide | download patch | download mbox

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 1337ffb527..437b848248 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1658,6 +1658,9 @@  end:
         frame->height = avctx->height;
     }
 
+    if (ret < 0)
+        av_frame_unref(frame);
+
     return ret;
 }