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
36473647 s->HEVClcList = av_mallocz(sizeof(HEVCLocalContext*) * s->threads_number);
36483648 s->sList = av_mallocz(sizeof(HEVCContext*) * s->threads_number);
36493649 if (!s->HEVClc || !s->HEVClcList || !s->sList)
3650− goto fail;
3650+ return AVERROR(ENOMEM);
36513651 s->HEVClcList[0] = s->HEVClc;
36523652 s->sList[0] = s;
36533653
36543654 s->cabac_state = av_malloc(HEVC_CONTEXTS);
36553655 if (!s->cabac_state)
3656− goto fail;
3656+ return AVERROR(ENOMEM);
36573657
36583658 s->output_frame = av_frame_alloc();
36593659 if (!s->output_frame)
3660− goto fail;
3660+ return AVERROR(ENOMEM);
36613661
36623662 for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
36633663 s->DPB[i].frame = av_frame_alloc();
36643664 if (!s->DPB[i].frame)
3665− goto fail;
3665+ return AVERROR(ENOMEM);
36663666 s->DPB[i].tf.f = s->DPB[i].frame;
36673667
36683668 s->DPB[i].frame_grain = av_frame_alloc();
36693669 if (!s->DPB[i].frame_grain)
3670− goto fail;
3670+ return AVERROR(ENOMEM);
36713671 }
36723672
36733673 s->max_ra = INT_MAX;
36743674
36753675 s->md5_ctx = av_md5_alloc();
36763676 if (!s->md5_ctx)
3677− goto fail;
3677+ return AVERROR(ENOMEM);
36783678
36793679 ff_bswapdsp_init(&s->bdsp);
36803680
@@ -3684,10 +3684,6 @@ static av_cold int hevc_init_context(AVCodecContext *avctx) · 3 unmodified lines
36843684 ff_hevc_reset_sei(&s->sei);
36853685
36863686 return 0;
3687−
3688−fail:
3689− hevc_decode_free(avctx);
3690− return AVERROR(ENOMEM);
36913687 }
36923688
36933689 #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