diff options
Diffstat (limited to 'libavcodec/xsubdec.c')
-rw-r--r-- | libavcodec/xsubdec.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index d01b410..1bb90e2 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -2,20 +2,20 @@ * XSUB subtitle decoder * Copyright (c) 2007 Reimar Döffinger * - * 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 */ @@ -58,11 +58,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, GetBitContext gb; int has_alpha = avctx->codec_tag == MKTAG('D','X','S','A'); - memset(sub, 0, sizeof(*sub)); - // check that at least header fits if (buf_size < 27 + 7 * 2 + 4 * (3 + has_alpha)) { - av_log(avctx, AV_LOG_ERROR, "coded frame too small\n"); + av_log(avctx, AV_LOG_ERROR, "coded frame size %d too small\n", buf_size); return -1; } @@ -95,8 +93,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, // allocate sub and set values sub->rects = av_mallocz(sizeof(*sub->rects)); + if (!sub->rects) + return AVERROR(ENOMEM); + sub->rects[0] = av_mallocz(sizeof(*sub->rects[0])); - sub->num_rects = 1; + if (!sub->rects[0]) { + av_freep(&sub->rects); + return AVERROR(ENOMEM); + } sub->rects[0]->x = x; sub->rects[0]->y = y; sub->rects[0]->w = w; sub->rects[0]->h = h; sub->rects[0]->type = SUBTITLE_BITMAP; @@ -104,6 +108,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, sub->rects[0]->pict.data[0] = av_malloc(w * h); sub->rects[0]->nb_colors = 4; sub->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE); + if (!sub->rects[0]->pict.data[0] || !sub->rects[0]->pict.data[1]) { + av_freep(&sub->rects[0]); + av_freep(&sub->rects); + return AVERROR(ENOMEM); + + } + sub->num_rects = 1; // read palette for (i = 0; i < sub->rects[0]->nb_colors; i++) |