... | ... |
@@ -646,8 +646,8 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data, |
646 | 646 |
av_log(avctx, AV_LOG_ERROR, |
647 | 647 |
"Invalid frame dimensions %dx%d\n", |
648 | 648 |
c->width, c->height); |
649 |
- c->width = c->height = 0; |
|
650 |
- bytestream2_skip(&bc, bytestream2_get_bytes_left(&bc)); |
|
649 |
+ ret = AVERROR_INVALIDDATA; |
|
650 |
+ goto header_fail; |
|
651 | 651 |
} |
652 | 652 |
if (c->width != avctx->width || c->height != avctx->height) |
653 | 653 |
avcodec_set_dimensions(avctx, c->width, c->height); |
... | ... |
@@ -664,15 +664,18 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data, |
664 | 664 |
av_log(avctx, AV_LOG_ERROR, |
665 | 665 |
"Invalid tile dimensions %dx%d\n", |
666 | 666 |
c->tile_width, c->tile_height); |
667 |
- return AVERROR_INVALIDDATA; |
|
667 |
+ ret = AVERROR_INVALIDDATA; |
|
668 |
+ goto header_fail; |
|
668 | 669 |
} |
669 | 670 |
c->tiles_x = (c->width + c->tile_width - 1) / c->tile_width; |
670 | 671 |
c->tiles_y = (c->height + c->tile_height - 1) / c->tile_height; |
671 | 672 |
c->bpp = bytestream2_get_byte(&bc); |
672 | 673 |
chunk_size -= 21; |
673 | 674 |
bytestream2_skip(&bc, chunk_size); |
674 |
- if (g2m_init_buffers(c)) |
|
675 |
- return AVERROR(ENOMEM); |
|
675 |
+ if (g2m_init_buffers(c)) { |
|
676 |
+ ret = AVERROR(ENOMEM); |
|
677 |
+ goto header_fail; |
|
678 |
+ } |
|
676 | 679 |
got_header = 1; |
677 | 680 |
break; |
678 | 681 |
case TILE_DATA: |
... | ... |
@@ -778,6 +781,10 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data, |
778 | 778 |
} |
779 | 779 |
|
780 | 780 |
return buf_size; |
781 |
+header_fail: |
|
782 |
+ c->width = c->height = 0; |
|
783 |
+ c->tiles_x = c->tiles_y = 0; |
|
784 |
+ return ret; |
|
781 | 785 |
} |
782 | 786 |
|
783 | 787 |
static av_cold int g2m_decode_init(AVCodecContext *avctx) |