diff options
author | Janne Grunau <janne-libav@jannau.net> | 2013-05-06 22:27:33 +0200 |
---|---|---|
committer | Janne Grunau <janne-libav@jannau.net> | 2013-05-06 22:27:33 +0200 |
commit | 45a1694fde251ee56e23aec073d73172c00aa470 (patch) | |
tree | b5b0be0abd1c03e35c31e2aac9f8dc3a968f2599 | |
parent | 851465f9d9edaa1c233ed72f2a510119d0151928 (diff) | |
download | ffmpeg-45a1694fde251ee56e23aec073d73172c00aa470.tar.gz |
jpeg2000dec: cleanup properly after decoding errors
Fixes memory leak in fate-redcode-demux.
-rw-r--r-- | libavcodec/jpeg2000dec.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index d29789f60d..97e706a020 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -1285,26 +1285,27 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data, return -1; } if (ret = jpeg2000_read_main_headers(s)) - return ret; + goto end; /* get picture buffer */ if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "ff_thread_get_buffer() failed.\n"); - return ret; + goto end; } picture->pict_type = AV_PICTURE_TYPE_I; picture->key_frame = 1; if (ret = jpeg2000_read_bitstream_packets(s)) - return ret; + goto end; for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++) if (ret = jpeg2000_decode_tile(s, s->tile + tileno, picture)) - return ret; - jpeg2000_dec_cleanup(s); + goto end; *got_frame = 1; - return s->buf - s->buf_start; +end: + jpeg2000_dec_cleanup(s); + return ret ? ret : s->buf - s->buf_start; } #define OFFSET(x) offsetof(Jpeg2000DecoderContext, x) |