From f369b9356c4606cd4d713d60f7db5de119d901fa Mon Sep 17 00:00:00 2001 From: Alexandra Khirnova Date: Tue, 10 Sep 2013 11:57:35 +0200 Subject: avformat: Use av_reallocp_array() where suitable Signed-off-by: Diego Biurrun --- libavformat/oggdec.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'libavformat/oggdec.c') diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index d22d5bc5b8..023492d969 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -84,7 +84,7 @@ static int ogg_restore(AVFormatContext *s, int discard) struct ogg *ogg = s->priv_data; AVIOContext *bc = s->pb; struct ogg_state *ost = ogg->state; - int i; + int i, err; if (!ost) return 0; @@ -92,7 +92,6 @@ static int ogg_restore(AVFormatContext *s, int discard) ogg->state = ost->next; if (!discard) { - struct ogg_stream *old_streams = ogg->streams; for (i = 0; i < ogg->nstreams; i++) av_free(ogg->streams[i].buf); @@ -100,16 +99,13 @@ static int ogg_restore(AVFormatContext *s, int discard) avio_seek(bc, ost->pos, SEEK_SET); ogg->curidx = ost->curidx; ogg->nstreams = ost->nstreams; - ogg->streams = av_realloc(ogg->streams, - ogg->nstreams * sizeof(*ogg->streams)); - - if (ogg->streams) { + if ((err = av_reallocp_array(&ogg->streams, ogg->nstreams, + sizeof(*ogg->streams))) < 0) { + ogg->nstreams = 0; + return err; + } else memcpy(ogg->streams, ost->streams, ost->nstreams * sizeof(*ogg->streams)); - } else { - av_free(old_streams); - ogg->nstreams = 0; - } } av_free(ost); -- cgit v1.2.3