diff mbox

[FFmpeg-devel] avcodec: set correct return value in ff_mpeg_ref_picture

Message ID 1511786470-31250-1-git-send-email-bianpan2016@163.com
State Accepted
Commit 89f9332fdf8948daa50a29e1a9fa9488041351a3
Headers show

Commit Message

Pan Bian Nov. 27, 2017, 12:41 p.m. UTC
In function ff_mpeg_ref_picture(), it returns 0 on the error path that
the return value of av_buffer_ref() is NULL. 0 indicates success, which
seems to deviate from the fact. Set ret to AVERROR(ENOMEM) to propagate
the error status to the callers.

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 libavcodec/mpegpicture.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Nov. 28, 2017, 7:36 p.m. UTC | #1
On Mon, Nov 27, 2017 at 08:41:10PM +0800, Pan Bian wrote:
> In function ff_mpeg_ref_picture(), it returns 0 on the error path that
> the return value of av_buffer_ref() is NULL. 0 indicates success, which
> seems to deviate from the fact. Set ret to AVERROR(ENOMEM) to propagate
> the error status to the callers.
> 
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
>  libavcodec/mpegpicture.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

will apply

thanks

[...]
diff mbox

Patch

diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index 2b72346..2be670c 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -375,8 +375,10 @@  int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src)
 
     if (src->hwaccel_picture_private) {
         dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
-        if (!dst->hwaccel_priv_buf)
+        if (!dst->hwaccel_priv_buf) {
+            ret = AVERROR(ENOMEM);
             goto fail;
+        }
         dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
     }