diff mbox series

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

Message ID 20200104185249.8563-1-george@nsup.org
State New
Headers show
Series [FFmpeg-devel] lavu/buffer: forward av_buffer_realloc() error code.
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Nicolas George Jan. 4, 2020, 6:52 p.m. UTC
Fix CID 1457235.

Signed-off-by: Nicolas George <george@nsup.org>
---
 libavutil/buffer.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Andreas Rheinhardt Jan. 4, 2020, 6:57 p.m. UTC | #1
Nicolas George:
> Fix CID 1457235.
> 
> Signed-off-by: Nicolas George <george@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));
>  
>
Paul B Mahol Jan. 4, 2020, 7:04 p.m. UTC | #2
On 1/4/20, Nicolas George <george@nsup.org> wrote:
> Fix CID 1457235.
>
> Signed-off-by: Nicolas George <george@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)
> -            return AVERROR(ENOMEM);
> +            return ret;
>
>          memcpy(new->data, buf->data, FFMIN(size, buf->size));
>
> --
> 2.24.1
>

OK

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Nicolas George Jan. 4, 2020, 7:08 p.m. UTC | #3
Andreas Rheinhardt (12020-01-04):
> Shouldn't you check for (ret < 0) instead of (!new)? I am unsure
> whether Coverity will really count this as a fix.

I hesitated and went for the minimalist patch. New version.

Regards,
diff mbox series

Patch

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)
-            return AVERROR(ENOMEM);
+            return ret;
 
         memcpy(new->data, buf->data, FFMIN(size, buf->size));