summaryrefslogtreecommitdiff
path: root/libavformat/oggdec.c
diff options
context:
space:
mode:
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);