Re: [libav-devel] [PATCH 12/12] hwcontext: Fix memory leak on derived frame allocation failure

2018-01-29 Thread Luca Barbato

On 30/01/2018 00:01, Mark Thompson wrote:

---
  libavutil/hwcontext.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 3ac17572b..34fb720a7 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -467,8 +467,10 @@ int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, 
AVFrame *frame, int flags)
  
  ret = av_hwframe_get_buffer(ctx->internal->source_frames,

  src_frame, 0);
-if (ret < 0)
+if (ret < 0) {
+av_frame_free(_frame);
  return ret;
+}
  
  ret = av_hwframe_map(frame, src_frame,

   ctx->internal->source_allocation_map_flags);



Ok.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 12/12] hwcontext: Fix memory leak on derived frame allocation failure

2018-01-29 Thread Mark Thompson
---
 libavutil/hwcontext.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 3ac17572b..34fb720a7 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -467,8 +467,10 @@ int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, 
AVFrame *frame, int flags)
 
 ret = av_hwframe_get_buffer(ctx->internal->source_frames,
 src_frame, 0);
-if (ret < 0)
+if (ret < 0) {
+av_frame_free(_frame);
 return ret;
+}
 
 ret = av_hwframe_map(frame, src_frame,
  ctx->internal->source_allocation_map_flags);
-- 
2.11.0

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel