---
libavformat/oggdec.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index ae9da3a..d5c1306 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -63,6 +63,9 @@ static int ogg_save(AVFormatContext *s)
struct ogg_state *ost =
av_malloc(sizeof(*ost) + (ogg->nstreams - 1) * sizeof(*ogg->streams));
int i;
+
+ if (!ost) return AVERROR(ENOMEM);
+
ost->pos = avio_tell(s->pb);
ost->curidx = ogg->curidx;
ost->next = ogg->state;
@@ -72,6 +75,7 @@ static int ogg_save(AVFormatContext *s)
for (i = 0; i < ogg->nstreams; i++) {
struct ogg_stream *os = ogg->streams + i;
os->buf = av_mallocz(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE);
+ if (!os->buf) return AVERROR(ENOMEM);
memcpy(os->buf, ost->streams[i].buf, os->bufpos);
}
@@ -173,6 +177,8 @@ static int ogg_new_stream(AVFormatContext *s, uint32_t
serial, int new_avstream)
os->header = -1;
os->start_granule = OGG_NOGRANULE_VALUE;
+ if (!os->buf) return AVERROR(ENOMEM);
+
if (new_avstream) {
st = avformat_new_stream(s, NULL);
if (!st)
@@ -191,6 +197,8 @@ static int ogg_new_buf(struct ogg *ogg, int idx)
uint8_t *nb = av_malloc(os->bufsize + FF_INPUT_BUFFER_PADDING_SIZE);
int size = os->bufpos - os->pstart;
+ if(!nb) return AVERROR(ENOMEM);
+
if (os->buf) {
memcpy(nb, os->buf + os->pstart, size);
av_free(os->buf);
@@ -276,8 +284,10 @@ static int ogg_read_page(AVFormatContext *s, int *str)
os = ogg->streams + idx;
os->page_pos = avio_tell(bc) - 27;
- if (os->psize > 0)
- ogg_new_buf(ogg, idx);
+ if (os->psize > 0) {
+ ret = ogg_new_buf(ogg, idx);
+ if (ret < 0) return ret;
+ }
ret = avio_read(bc, os->segments, nsegs);
if (ret < nsegs)
--
1.7.9.2
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel