diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-01-19 17:15:15 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-01-19 17:15:15 +0100 |
commit | f9a5a89bbfdef991523921f4733217009946eec4 (patch) | |
tree | 723ba44d5b3457c09a8d1c8b7a5214f9d2586012 /libavcodec/xsubdec.c | |
parent | 438c0a665af3a368b49011d5ec109d9031090dfc (diff) | |
download | ffmpeg-f9a5a89bbfdef991523921f4733217009946eec4.tar.gz |
avcodec/xsubdec: Check av_mallocz() return codes
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/xsubdec.c')
-rw-r--r-- | libavcodec/xsubdec.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 94a68e2bb4..1bb90e2b9d 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -93,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; @@ -102,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++) |