Commit 00e1bf8a authored by Paul B Mahol's avatar Paul B Mahol

avformat/flic: check for memory allocation failures

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 803445e0
...@@ -125,8 +125,10 @@ static int flic_read_header(AVFormatContext *s) ...@@ -125,8 +125,10 @@ static int flic_read_header(AVFormatContext *s)
} }
/* send over the whole 128-byte FLIC header */ /* send over the whole 128-byte FLIC header */
st->codec->extradata_size = FLIC_HEADER_SIZE;
st->codec->extradata = av_malloc(FLIC_HEADER_SIZE); st->codec->extradata = av_malloc(FLIC_HEADER_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = FLIC_HEADER_SIZE;
memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE); memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE);
/* peek at the preamble to detect TFTD videos - they seem to always start with an audio chunk */ /* peek at the preamble to detect TFTD videos - they seem to always start with an audio chunk */
...@@ -176,8 +178,10 @@ static int flic_read_header(AVFormatContext *s) ...@@ -176,8 +178,10 @@ static int flic_read_header(AVFormatContext *s)
/* send over abbreviated FLIC header chunk */ /* send over abbreviated FLIC header chunk */
av_free(st->codec->extradata); av_free(st->codec->extradata);
st->codec->extradata_size = 12;
st->codec->extradata = av_malloc(12); st->codec->extradata = av_malloc(12);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = 12;
memcpy(st->codec->extradata, header, 12); memcpy(st->codec->extradata, header, 12);
} else if (magic_number == FLIC_FILE_MAGIC_1) { } else if (magic_number == FLIC_FILE_MAGIC_1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment