Re: [libav-devel] [PATCH 5/5] libdav1d: unref the frame on failure

2019-03-22 Thread Luca Barbato

On 15/03/2019 23:44, James Almer wrote:

---
  libavcodec/libdav1d.c | 11 ---
  1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 83d5c97bc..5177b884c 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -230,7 +230,7 @@ static int libdav1d_receive_frame(AVCodecContext *c, 
AVFrame *frame)
  if (c->width != p->p.w || c->height != p->p.h) {
  res = ff_set_dimensions(c, p->p.w, p->p.h);
  if (res < 0)
-return res;
+goto fail;
  }
  
  switch (p->seq_hdr->chr) {

@@ -268,10 +268,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
  frame->pict_type = AV_PICTURE_TYPE_SP;
  break;
  default:
-return AVERROR_INVALIDDATA;
+res = AVERROR_INVALIDDATA;
+goto fail;
  }
  
-return 0;

+res = 0;
+fail:
+if (res < 0)
+av_frame_unref(frame);
+return res;
  }
  
  static av_cold int libdav1d_close(AVCodecContext *c)




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

[libav-devel] [PATCH 5/5] libdav1d: unref the frame on failure

2019-03-15 Thread James Almer
---
 libavcodec/libdav1d.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 83d5c97bc..5177b884c 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -230,7 +230,7 @@ static int libdav1d_receive_frame(AVCodecContext *c, 
AVFrame *frame)
 if (c->width != p->p.w || c->height != p->p.h) {
 res = ff_set_dimensions(c, p->p.w, p->p.h);
 if (res < 0)
-return res;
+goto fail;
 }
 
 switch (p->seq_hdr->chr) {
@@ -268,10 +268,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
 frame->pict_type = AV_PICTURE_TYPE_SP;
 break;
 default:
-return AVERROR_INVALIDDATA;
+res = AVERROR_INVALIDDATA;
+goto fail;
 }
 
-return 0;
+res = 0;
+fail:
+if (res < 0)
+av_frame_unref(frame);
+return res;
 }
 
 static av_cold int libdav1d_close(AVCodecContext *c)
-- 
2.21.0

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