oggdec: check memory allocation
(cherry picked from commit ba064ebe48
)
Conflicts:
libavformat/oggdec.c
This commit is contained in:

committed by
Reinhard Tartler

parent
c3761b6618
commit
fe4409a396
@@ -159,8 +159,13 @@ ogg_new_stream (AVFormatContext * s, uint32_t serial)
|
|||||||
AVStream *st;
|
AVStream *st;
|
||||||
struct ogg_stream *os;
|
struct ogg_stream *os;
|
||||||
|
|
||||||
ogg->streams = av_realloc (ogg->streams,
|
os = av_realloc (ogg->streams, ogg->nstreams * sizeof (*ogg->streams));
|
||||||
ogg->nstreams * sizeof (*ogg->streams));
|
|
||||||
|
if (!os)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
ogg->streams = os;
|
||||||
|
|
||||||
memset (ogg->streams + idx, 0, sizeof (*ogg->streams));
|
memset (ogg->streams + idx, 0, sizeof (*ogg->streams));
|
||||||
os = ogg->streams + idx;
|
os = ogg->streams + idx;
|
||||||
os->serial = serial;
|
os->serial = serial;
|
||||||
@@ -279,6 +284,8 @@ ogg_read_page (AVFormatContext * s, int *str)
|
|||||||
|
|
||||||
if (os->bufsize - os->bufpos < size){
|
if (os->bufsize - os->bufpos < size){
|
||||||
uint8_t *nb = av_malloc ((os->bufsize *= 2) + FF_INPUT_BUFFER_PADDING_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);
|
memcpy (nb, os->buf, os->bufpos);
|
||||||
av_free (os->buf);
|
av_free (os->buf);
|
||||||
os->buf = nb;
|
os->buf = nb;
|
||||||
|
Reference in New Issue
Block a user