diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-10-28 20:53:11 +0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-10-29 23:06:32 +0400 |
commit | 47b617021dffab86b5594f6c08aa304dee7bbbc0 (patch) | |
tree | 451a07f30a87d54c45a04b8ec6dfb9f5da9c526a /libavcodec/atrac3.c | |
parent | c91613857d618080af2cb61260c9391a1b23f75e (diff) |
atrac3: make sure all memory is freed on init failure
Diffstat (limited to 'libavcodec/atrac3.c')
-rw-r--r-- | libavcodec/atrac3.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 76ceac8571..80aa9c8b4c 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -196,7 +196,7 @@ static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ } -static av_cold void init_atrac3_transforms(ATRAC3Context *q) { +static av_cold int init_atrac3_transforms(ATRAC3Context *q) { float enc_window[256]; int i; @@ -212,7 +212,7 @@ static av_cold void init_atrac3_transforms(ATRAC3Context *q) { } /* Initialize the MDCT transform. */ - ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0 / 32768); + return ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0 / 32768); } /** @@ -880,7 +880,7 @@ static int atrac3_decode_frame(AVCodecContext *avctx, static av_cold int atrac3_decode_init(AVCodecContext *avctx) { - int i; + int i, ret; const uint8_t *edata_ptr = avctx->extradata; ATRAC3Context *q = avctx->priv_data; static VLC_TYPE atrac3_vlc_table[4096][2]; @@ -986,7 +986,11 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) vlcs_initialized = 1; } - init_atrac3_transforms(q); + if ((ret = init_atrac3_transforms(q))) { + av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n"); + av_freep(&q->decoded_bytes_buffer); + return ret; + } atrac_generate_tables(); @@ -1016,7 +1020,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) q->pUnits = av_mallocz(sizeof(channel_unit)*q->channels); if (!q->pUnits) { - av_free(q->decoded_bytes_buffer); + atrac3_decode_close(avctx); return AVERROR(ENOMEM); } |