diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2013-07-01 10:01:28 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2013-07-02 20:05:47 +0200 |
commit | daeb4e3042f2ecae2d41aaa4cae0bed932539788 (patch) | |
tree | ad711de4d660f219c50a1918b787c6b2ecbd395f /libavcodec/jpeg2000dec.c | |
parent | 589e5b52f634f6b2d307a167a19eef7e7328cb08 (diff) | |
download | ffmpeg-daeb4e3042f2ecae2d41aaa4cae0bed932539788.tar.gz |
jpeg2000: Proper cleanup on failure in decode_frame()
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Diffstat (limited to 'libavcodec/jpeg2000dec.c')
-rw-r--r-- | libavcodec/jpeg2000dec.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 346a5c6867..15dfc2bcd3 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -1346,8 +1346,10 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data, bytestream2_init(&s->g, avpkt->data, avpkt->size); s->curtileno = 0; // TODO: only one tile in DCI JP2K. to implement for more tiles - if (bytestream2_get_bytes_left(&s->g) < 2) - return AVERROR_INVALIDDATA; + if (bytestream2_get_bytes_left(&s->g) < 2) { + ret = AVERROR_INVALIDDATA; + goto end; + } // check if the image is in jp2 format if (bytestream2_get_bytes_left(&s->g) >= 12 && @@ -1357,17 +1359,17 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data, if (!jp2_find_codestream(s)) { av_log(avctx, AV_LOG_ERROR, "Could not find Jpeg2000 codestream atom.\n"); - return AVERROR_INVALIDDATA; + ret = AVERROR_INVALIDDATA; + goto end; } } else { bytestream2_seek(&s->g, 0, SEEK_SET); - if (bytestream2_peek_be16(&s->g) != JPEG2000_SOC) - bytestream2_skip(&s->g, 8); } if (bytestream2_get_be16u(&s->g) != JPEG2000_SOC) { av_log(avctx, AV_LOG_ERROR, "SOC marker not present\n"); - return AVERROR_INVALIDDATA; + ret = AVERROR_INVALIDDATA; + goto end; } if (ret = jpeg2000_read_main_headers(s)) goto end; @@ -1386,6 +1388,8 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, void *data, if (ret = jpeg2000_decode_tile(s, s->tile + tileno, picture)) goto end; + jpeg2000_dec_cleanup(s); + *got_frame = 1; return bytestream2_tell(&s->g); |