On 9/22/2019 11:06 AM, lance.lmw...@gmail.com wrote: > From: Limin Wang <lance.lmw...@gmail.com> > > Signed-off-by: Limin Wang <lance.lmw...@gmail.com> > --- > libavcodec/dnxhdenc.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c > index 41b8079..f144406 100644 > --- a/libavcodec/dnxhdenc.c > +++ b/libavcodec/dnxhdenc.c > @@ -365,7 +365,7 @@ fail: > static av_cold int dnxhd_encode_init(AVCodecContext *avctx) > { > DNXHDEncContext *ctx = avctx->priv_data; > - int i, index, ret; > + int i = 1, index, ret; > > switch (avctx->pix_fmt) { > case AV_PIX_FMT_YUV422P: > @@ -542,12 +542,15 @@ 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)); > } > } > > return 0; > fail: // for FF_ALLOCZ_OR_GOTO > + avctx->thread_count = i;
This is unnecessary. All ctx->thread[] array elements are zero initialized, so the av_freep() calls in dnxhd_encode_end() are safe for those that were never allocated. > return AVERROR(ENOMEM); > } > > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".