1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

oggdec: check memory allocation

This commit is contained in:
Luca Barbato 2012-12-22 17:58:24 +01:00
parent f5f1cf5224
commit ba064ebe48

View File

@ -160,8 +160,13 @@ static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream)
AVStream *st;
struct ogg_stream *os;
ogg->streams = av_realloc(ogg->streams,
ogg->nstreams * sizeof(*ogg->streams));
os = av_realloc(ogg->streams, ogg->nstreams * sizeof(*ogg->streams));
if (!os)
return AVERROR(ENOMEM);
ogg->streams = os;
memset(ogg->streams + idx, 0, sizeof(*ogg->streams));
os = ogg->streams + idx;
@ -305,6 +310,8 @@ static int ogg_read_page(AVFormatContext *s, int *str)
if (os->bufsize - os->bufpos < size) {
uint8_t *nb = av_malloc((os->bufsize *= 2) + FF_INPUT_BUFFER_PADDING_SIZE);
if (!nb)
return AVERROR(ENOMEM);
memcpy(nb, os->buf, os->bufpos);
av_free(os->buf);
os->buf = nb;