History

avcodec/hevcdec: Return immediately upon hevc_init_context() failure

This function is only called from the decoder's init function and given that this decoder has FF_CODEC_CAP_INIT_CLEANUP set, hevc_decode_free() is called automatically (currently it would be called twice with the second call being redundant).

Andreas Rheinhardt committed 4 years ago

Commit 03b2ed91 parent a3b833c1 file · +6 −10Browse files

Unified · Split

libavcodec/hevcdec.c+6−10
@@ -3647,34 +3647,34 @@ static av_cold int hevc_init_context(AVCodecContext *avctx) · 3646 unmodified lines
3647 s->HEVClcList = av_mallocz(sizeof(HEVCLocalContext*) * s->threads_number);3647 s->HEVClcList = av_mallocz(sizeof(HEVCLocalContext*) * s->threads_number);
3648 s->sList = av_mallocz(sizeof(HEVCContext*) * s->threads_number);3648 s->sList = av_mallocz(sizeof(HEVCContext*) * s->threads_number);
3649 if (!s->HEVClc || !s->HEVClcList || !s->sList)3649 if (!s->HEVClc || !s->HEVClcList || !s->sList)
3650 goto fail;3650 return AVERROR(ENOMEM);
3651 s->HEVClcList[0] = s->HEVClc;3651 s->HEVClcList[0] = s->HEVClc;
3652 s->sList[0] = s;3652 s->sList[0] = s;
3653 3653
3654 s->cabac_state = av_malloc(HEVC_CONTEXTS);3654 s->cabac_state = av_malloc(HEVC_CONTEXTS);
3655 if (!s->cabac_state)3655 if (!s->cabac_state)
3656 goto fail;3656 return AVERROR(ENOMEM);
3657 3657
3658 s->output_frame = av_frame_alloc();3658 s->output_frame = av_frame_alloc();
3659 if (!s->output_frame)3659 if (!s->output_frame)
3660 goto fail;3660 return AVERROR(ENOMEM);
3661 3661
3662 for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {3662 for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
3663 s->DPB[i].frame = av_frame_alloc();3663 s->DPB[i].frame = av_frame_alloc();
3664 if (!s->DPB[i].frame)3664 if (!s->DPB[i].frame)
3665 goto fail;3665 return AVERROR(ENOMEM);
3666 s->DPB[i].tf.f = s->DPB[i].frame;3666 s->DPB[i].tf.f = s->DPB[i].frame;
3667 3667
3668 s->DPB[i].frame_grain = av_frame_alloc();3668 s->DPB[i].frame_grain = av_frame_alloc();
3669 if (!s->DPB[i].frame_grain)3669 if (!s->DPB[i].frame_grain)
3670 goto fail;3670 return AVERROR(ENOMEM);
3671 }3671 }
3672 3672
3673 s->max_ra = INT_MAX;3673 s->max_ra = INT_MAX;
3674 3674
3675 s->md5_ctx = av_md5_alloc();3675 s->md5_ctx = av_md5_alloc();
3676 if (!s->md5_ctx)3676 if (!s->md5_ctx)
3677 goto fail;3677 return AVERROR(ENOMEM);
3678 3678
3679 ff_bswapdsp_init(&s->bdsp);3679 ff_bswapdsp_init(&s->bdsp);
3680 3680
@@ -3684,10 +3684,6 @@ static av_cold int hevc_init_context(AVCodecContext *avctx) · 3 unmodified lines
3684 ff_hevc_reset_sei(&s->sei);3684 ff_hevc_reset_sei(&s->sei);
3685 3685
3686 return 0;3686 return 0;
3687
3688fail:
3689 hevc_decode_free(avctx);
3690 return AVERROR(ENOMEM);
3691}3687}
3692 3688
3693#if HAVE_THREADS3689#if HAVE_THREADS

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t