summaryrefslogtreecommitdiff
path: root/libavformat/oggdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-09-11 10:54:41 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-09-11 11:23:40 +0200
commitcbe47b1e8452e37fda592941e7d3f3bb5920c201 (patch)
tree9ea8b6418c4d89e27c98314d41974163b5dbafe8 /libavformat/oggdec.c
parent64b6279d1414378214a58a55f0066fbc95256c9b (diff)
parentf369b9356c4606cd4d713d60f7db5de119d901fa (diff)
Merge commit 'f369b9356c4606cd4d713d60f7db5de119d901fa'
* commit 'f369b9356c4606cd4d713d60f7db5de119d901fa': avformat: Use av_reallocp_array() where suitable Conflicts: libavformat/asfenc.c libavformat/gxfenc.c libavformat/mov.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
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 03a2618bec..9c560a88af 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -88,7 +88,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;
@@ -96,7 +96,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);
@@ -105,16 +104,13 @@ static int ogg_restore(AVFormatContext *s, int discard)
ogg->page_pos = -1;
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);