---
 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
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to