History

avcodec/mpegaudiodec*: Cleanup generically on init failure

Andreas Rheinhardt committed 6 years ago

Commit c7867b61 parent e9831b13 files · +5 −8Browse files

Unified · Split

3 files
  1. libavcodec/mpegaudiodec_fixed.c +1 −0
  2. libavcodec/mpegaudiodec_float.c +1 −0
  3. libavcodec/mpegaudiodec_template.c +3 −8
libavcodec/mpegaudiodec_fixed.c+1−0
@@ -116,5 +116,6 @@ AVCodec ff_mp3on4_decoder = { · 115 unmodified lines
116116 .flush = flush_mp3on4,
117117 .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P,
118118 AV_SAMPLE_FMT_NONE },
119+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
119120 };
120121 #endif
libavcodec/mpegaudiodec_float.c+1−0
@@ -116,5 +116,6 @@ AVCodec ff_mp3on4float_decoder = { · 115 unmodified lines
116116 .flush = flush_mp3on4,
117117 .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
118118 AV_SAMPLE_FMT_NONE },
119+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
119120 };
120121 #endif
libavcodec/mpegaudiodec_template.c+3−8
@@ -1908,16 +1908,14 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) · 1907 unmodified lines
19081908 // Allocate zeroed memory for the first decoder context
19091909 s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext));
19101910 if (!s->mp3decctx[0])
1911− goto alloc_fail;
1911+ return AVERROR(ENOMEM);
19121912 // Put decoder context in place to make init_decode() happy
19131913 avctx->priv_data = s->mp3decctx[0];
19141914 ret = decode_init(avctx);
19151915 // Restore mp3on4 context pointer
19161916 avctx->priv_data = s;
1917− if (ret < 0) {
1918− decode_close_mp3on4(avctx);
1917+ if (ret < 0)
19191918 return ret;
1920− }
19211919 s->mp3decctx[0]->adu_mode = 1; // Set adu mode
19221920
19231921 /* Create a separate codec/context for each frame (first is already ok).
@@ -1926,7 +1924,7 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) · 2 unmodified lines
19261924 for (i = 1; i < s->frames; i++) {
19271925 s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext));
19281926 if (!s->mp3decctx[i])
1929− goto alloc_fail;
1927+ return AVERROR(ENOMEM);
19301928 s->mp3decctx[i]->adu_mode = 1;
19311929 s->mp3decctx[i]->avctx = avctx;
19321930 s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp;
@@ -1934,9 +1932,6 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx) · 1 unmodified line
19341932 }
19351933
19361934 return 0;
1937−alloc_fail:
1938− decode_close_mp3on4(avctx);
1939− return AVERROR(ENOMEM);
19401935 }
19411936
19421937

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