summaryrefslogtreecommitdiff
path: root/libavcodec/tta.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-02-11 02:06:24 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-02-11 02:06:24 +0100
commited83f97235b6b3bd2cf62830bba00dfd7327d389 (patch)
tree1614d17eb7c70185aa56fff3ed0234de0f29c830 /libavcodec/tta.c
parentc6abf214923ae8ee07456c5594f632a10499442b (diff)
tta: Add some safety precautions to avoid freeing things that have not been allocated.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/tta.c')
-rw-r--r--libavcodec/tta.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/tta.c b/libavcodec/tta.c
index 0e3bbd224c..6b8e0e9e19 100644
--- a/libavcodec/tta.c
+++ b/libavcodec/tta.c
@@ -283,7 +283,8 @@ static av_cold int tta_decode_init(AVCodecContext * avctx)
s->decode_buffer = av_mallocz(sizeof(int32_t)*s->frame_length*s->channels);
if (!s->decode_buffer)
return AVERROR(ENOMEM);
- }
+ } else
+ s->decode_buffer = NULL;
s->ch_ctx = av_malloc(avctx->channels * sizeof(*s->ch_ctx));
if (!s->ch_ctx) {
av_freep(&s->decode_buffer);
@@ -449,7 +450,9 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,
static av_cold int tta_decode_close(AVCodecContext *avctx) {
TTAContext *s = avctx->priv_data;
- av_free(s->decode_buffer);
+ if (s->bps < 3)
+ av_free(s->decode_buffer);
+ s->decode_buffer = NULL;
av_freep(&s->ch_ctx);
return 0;