diff options
Diffstat (limited to 'libavcodec/cdgraphics.c')
-rw-r--r-- | libavcodec/cdgraphics.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c index 8be1460..d22e9f6 100644 --- a/libavcodec/cdgraphics.c +++ b/libavcodec/cdgraphics.c @@ -2,20 +2,20 @@ * CD Graphics Video Decoder * Copyright (c) 2009 Michael Tison * - * 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 */ @@ -119,7 +119,7 @@ static void cdg_load_palette(CDGraphicsContext *cc, uint8_t *data, int low) r = ((color >> 8) & 0x000F) * 17; g = ((color >> 4) & 0x000F) * 17; b = ((color ) & 0x000F) * 17; - palette[i + array_offset] = r << 16 | g << 8 | b; + palette[i + array_offset] = 0xFFU << 24 | r << 16 | g << 8 | b; } cc->frame->palette_has_changed = 1; } @@ -273,14 +273,17 @@ static int cdg_decode_frame(AVCodecContext *avctx, av_log(avctx, AV_LOG_ERROR, "buffer too small for decoder\n"); return AVERROR(EINVAL); } + if (buf_size > CDG_HEADER_SIZE + CDG_DATA_SIZE) { + av_log(avctx, AV_LOG_ERROR, "buffer too big for decoder\n"); + return AVERROR(EINVAL); + } - ret = ff_reget_buffer(avctx, cc->frame); - if (ret) { - av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); + if ((ret = ff_reget_buffer(avctx, cc->frame)) < 0) return ret; - } - if (!avctx->frame_number) + if (!avctx->frame_number) { memset(cc->frame->data[0], 0, cc->frame->linesize[0] * avctx->height); + memset(cc->frame->data[1], 0, AVPALETTE_SIZE); + } command = bytestream_get_byte(&buf); inst = bytestream_get_byte(&buf); @@ -327,11 +330,8 @@ static int cdg_decode_frame(AVCodecContext *avctx, return AVERROR(EINVAL); } - ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF); - if (ret) { - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; - } cdg_scroll(cc, cdg_data, frame, inst == CDG_INST_SCROLL_COPY); av_frame_unref(cc->frame); |