[FFmpeg-devel] [PATCH] lavu/buffer: forward av_buffer_realloc() error code.

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sat Jan 4 20:57:00 EET 2020


Nicolas George:
> Fix CID 1457235.
> 
> Signed-off-by: Nicolas George <george at nsup.org>
> ---
>  libavutil/buffer.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/buffer.c b/libavutil/buffer.c
> index 6d9cb7428e..2f33e5ebb6 100644
> --- a/libavutil/buffer.c
> +++ b/libavutil/buffer.c
> @@ -171,6 +171,7 @@ int av_buffer_realloc(AVBufferRef **pbuf, int size)
>  {
>      AVBufferRef *buf = *pbuf;
>      uint8_t *tmp;
> +    int ret;
>  
>      if (!buf) {
>          /* allocate a new buffer with av_realloc(), so it will be reallocatable
> @@ -197,9 +198,9 @@ int av_buffer_realloc(AVBufferRef **pbuf, int size)
>          /* cannot realloc, allocate a new reallocable buffer and copy data */
>          AVBufferRef *new = NULL;
>  
> -        av_buffer_realloc(&new, size);
> +        ret = av_buffer_realloc(&new, size);
>          if (!new)

Shouldn't you check for (ret < 0) instead of (!new)? I am unsure
whether Coverity will really count this as a fix.

- Andreas

> -            return AVERROR(ENOMEM);
> +            return ret;
>  
>          memcpy(new->data, buf->data, FFMIN(size, buf->size));
>  
> 



More information about the ffmpeg-devel mailing list