diff mbox

[FFmpeg-devel,v3] avcodec/dnxhdenc: return error if av_malloc failed

Message ID 20190923033618.3652-1-lance.lmwang@gmail.com
State Accepted
Commit 3def984a98c3f374db974606013892f71c406af9
Headers show

Commit Message

Lance Wang Sept. 23, 2019, 3:36 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/dnxhdenc.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

James Almer Sept. 25, 2019, 8:57 p.m. UTC | #1
On 9/23/2019 12:36 AM, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavcodec/dnxhdenc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
> index 41b8079a09..c82c5d5140 100644
> --- a/libavcodec/dnxhdenc.c
> +++ b/libavcodec/dnxhdenc.c
> @@ -542,6 +542,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
>      if (avctx->active_thread_type == FF_THREAD_SLICE) {
>          for (i = 1; i < avctx->thread_count; i++) {
>              ctx->thread[i] = av_malloc(sizeof(DNXHDEncContext));
> +            if (!ctx->thread[i])
> +                goto fail;
>              memcpy(ctx->thread[i], ctx, sizeof(DNXHDEncContext));
>          }
>      }

Pushed.
diff mbox

Patch

diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 41b8079a09..c82c5d5140 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -542,6 +542,8 @@  FF_ENABLE_DEPRECATION_WARNINGS
     if (avctx->active_thread_type == FF_THREAD_SLICE) {
         for (i = 1; i < avctx->thread_count; i++) {
             ctx->thread[i] = av_malloc(sizeof(DNXHDEncContext));
+            if (!ctx->thread[i])
+                goto fail;
             memcpy(ctx->thread[i], ctx, sizeof(DNXHDEncContext));
         }
     }