summaryrefslogtreecommitdiff
path: root/libavformat/oggdec.c
diff options
context:
space:
mode:
authorAlexandra Khirnova <alexandra.khirnova@gmail.com>2013-09-10 11:57:35 +0200
committerDiego Biurrun <diego@biurrun.de>2013-09-10 12:38:32 +0200
commitf369b9356c4606cd4d713d60f7db5de119d901fa (patch)
tree174e199dd9716a32fbee4fb235d3938721fb333f /libavformat/oggdec.c
parentbdf990425e2be6912a6d29f032ca558448c8635a (diff)
avformat: Use av_reallocp_array() where suitable
Signed-off-by: Diego Biurrun <diego@biurrun.de>
Diffstat (limited to 'libavformat/oggdec.c')
-rw-r--r--libavformat/oggdec.c16
1 files changed, 6 insertions, 10 deletions
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);