Fixes: out of array read Fixes: Ticket 10308
Showing the changes to libavcodec (2 of 2 files). Show all
Unified · Split
| @@ -281,7 +281,7 @@ static int decode_slice(MpegEncContext *s) · 280 unmodified lines | ||
| 281 | 281 | ff_er_add_slice(&s->er, s->resync_mb_x, s->resync_mb_y, |
| 282 | 282 | s->mb_x, s->mb_y, ER_MB_ERROR & part_mask); |
| 283 | 283 | |
| 284 | − if (s->avctx->err_recognition & AV_EF_IGNORE_ERR) | |
| 284 | + if ((s->avctx->err_recognition & AV_EF_IGNORE_ERR) && get_bits_left(&s->gb) > 0) | |
| 285 | 285 | continue; |
| 286 | 286 | return AVERROR_INVALIDDATA; |
| 287 | 287 | } |
| @@ -1437,7 +1437,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, · 1436 unmodified lines | ||
| 1437 | 1437 | if (SHOW_UBITS(re, &s->gb, 1) == 0) { |
| 1438 | 1438 | av_log(s->avctx, AV_LOG_ERROR, |
| 1439 | 1439 | "1. marker bit missing in 3. esc\n"); |
| 1440 | − if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR)) | |
| 1440 | + if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&s->gb) <= 0) | |
| 1441 | 1441 | return AVERROR_INVALIDDATA; |
| 1442 | 1442 | } |
| 1443 | 1443 | SKIP_CACHE(re, &s->gb, 1); |
| @@ -1448,7 +1448,7 @@ static inline int mpeg4_decode_block(Mpeg4DecContext *ctx, int16_t *block, · 4 unmodified lines | ||
| 1448 | 1448 | if (SHOW_UBITS(re, &s->gb, 1) == 0) { |
| 1449 | 1449 | av_log(s->avctx, AV_LOG_ERROR, |
| 1450 | 1450 | "2. marker bit missing in 3. esc\n"); |
| 1451 | − if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR)) | |
| 1451 | + if (!(s->avctx->err_recognition & AV_EF_IGNORE_ERR) || get_bits_left(&s->gb) <= 0) | |
| 1452 | 1452 | return AVERROR_INVALIDDATA; |
| 1453 | 1453 | } |
| 1454 | 1454 | |