summaryrefslogtreecommitdiffstats
path: root/libavcodec/dvdsubdec.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-02-02 01:57:14 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-02-17 12:16:43 -0500
commitec17782e17de1e8501ca213e276dfe5412ff1d11 (patch)
treee2cf3d89f87df51f49e110034f8bcbcc1eecf37c /libavcodec/dvdsubdec.c
parente51f22122d23589e93ac4f0b3e570bb925755915 (diff)
downloadffmpeg-streaming-ec17782e17de1e8501ca213e276dfe5412ff1d11.zip
ffmpeg-streaming-ec17782e17de1e8501ca213e276dfe5412ff1d11.tar.gz
dvdsubdec: Check memory allocations
Diffstat (limited to 'libavcodec/dvdsubdec.c')
-rw-r--r--libavcodec/dvdsubdec.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index 15abac0..bc5a3a7 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -324,16 +324,23 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
sub_header->num_rects = 0;
}
- bitmap = av_malloc(w * h);
sub_header->rects = av_mallocz(sizeof(*sub_header->rects));
+ if (!sub_header->rects)
+ goto fail;
sub_header->rects[0] = av_mallocz(sizeof(AVSubtitleRect));
+ if (!sub_header->rects[0])
+ goto fail;
sub_header->num_rects = 1;
- sub_header->rects[0]->pict.data[0] = bitmap;
+ bitmap = sub_header->rects[0]->pict.data[0] = av_malloc(w * h);
+ if (!bitmap)
+ goto fail;
decode_rle(bitmap, w * 2, w, (h + 1) / 2,
buf, offset1, buf_size, is_8bit);
decode_rle(bitmap + w, w * 2, w, h / 2,
buf, offset2, buf_size, is_8bit);
sub_header->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
+ if (!sub_header->rects[0]->pict.data[1])
+ goto fail;
if (is_8bit) {
if (yuv_palette == 0)
goto fail;
OpenPOWER on IntegriCloud