diff options
Diffstat (limited to 'libavcodec/mss12.c')
-rw-r--r-- | libavcodec/mss12.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/libavcodec/mss12.c b/libavcodec/mss12.c index 8735b85..3b1a302 100644 --- a/libavcodec/mss12.c +++ b/libavcodec/mss12.c @@ -1,20 +1,20 @@ /* * Copyright (c) 2012 Konstantin Shishkov * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -451,7 +451,7 @@ static int decode_pivot(SliceContext *sc, ArithCoder *acoder, int base) val = acoder->get_number(acoder, (base + 1) / 2 - 2) + 3; } - if (val >= base) + if ((unsigned)val >= base) return -1; return inv ? base - val : val; @@ -582,22 +582,17 @@ av_cold int ff_mss12_decode_init(MSS12Context *c, int version, return AVERROR_INVALIDDATA; } - avctx->coded_width = AV_RB32(avctx->extradata + 20); - avctx->coded_height = AV_RB32(avctx->extradata + 24); + avctx->coded_width = FFMAX(AV_RB32(avctx->extradata + 20), avctx->width); + avctx->coded_height = FFMAX(AV_RB32(avctx->extradata + 24), avctx->height); if (avctx->coded_width > 4096 || avctx->coded_height > 4096) { av_log(avctx, AV_LOG_ERROR, "Frame dimensions %dx%d too large", avctx->coded_width, avctx->coded_height); return AVERROR_INVALIDDATA; } - if (avctx->width || avctx->height) { - if (avctx->width <= 0 || avctx->width > avctx->coded_width || - avctx->height <= 0 || avctx->height > avctx->coded_height) { - av_log(avctx, AV_LOG_ERROR, "Invalid display dimensions\n"); - return AVERROR_INVALIDDATA; - } - } else { - avctx->width = avctx->coded_width; - avctx->height = avctx->coded_height; + if (avctx->coded_width < 1 || avctx->coded_height < 1) { + av_log(avctx, AV_LOG_ERROR, "Frame dimensions %dx%d too small", + avctx->coded_width, avctx->coded_height); + return AVERROR_INVALIDDATA; } av_log(avctx, AV_LOG_DEBUG, "Encoder version %"PRIu32".%"PRIu32"\n", @@ -658,11 +653,11 @@ av_cold int ff_mss12_decode_init(MSS12Context *c, int version, } for (i = 0; i < 256; i++) - c->pal[i] = AV_RB24(avctx->extradata + 52 + + c->pal[i] = 0xFFU << 24 | AV_RB24(avctx->extradata + 52 + (version ? 8 : 0) + i * 3); c->mask_stride = FFALIGN(avctx->width, 16); - c->mask = av_malloc(c->mask_stride * avctx->height); + c->mask = av_malloc_array(c->mask_stride, avctx->height); if (!c->mask) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate mask plane\n"); return AVERROR(ENOMEM); |