aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-12-20 21:21:59 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-20 01:21:36 +0200
commite4fd6ef46adebb95616000bd07aa2b04108b435b (patch)
treec4c96178c504cc5cb7d60e3957a11d78fb6b89cb
parent2765e927315c87cede25d42fbcf4f1f41bfed5a5 (diff)
downloadffmpeg-e4fd6ef46adebb95616000bd07aa2b04108b435b.tar.gz
avformat/webmdashenc: Fix memleak upon realloc failure
The classical ptr = av_realloc(ptr, size). Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> (cherry picked from commit 418e468699868a0265f8b439beedf64bb643b088)
-rw-r--r--libavformat/webmdashenc.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index 26b8727304..14c3888b1e 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -489,11 +489,12 @@ static int parse_adaptation_sets(AVFormatContext *s)
state = parsing_streams;
} else if (state == parsing_streams) {
struct AdaptationSet *as = &w->as[w->nb_as - 1];
+ int ret = av_reallocp_array(&as->streams, ++as->nb_streams,
+ sizeof(*as->streams));
+ if (ret < 0)
+ return ret;
q = p;
while (*q != '\0' && *q != ',' && *q != ' ') q++;
- as->streams = av_realloc(as->streams, sizeof(*as->streams) * ++as->nb_streams);
- if (as->streams == NULL)
- return AVERROR(ENOMEM);
as->streams[as->nb_streams - 1] = to_integer(p, q - p + 1);
if (as->streams[as->nb_streams - 1] < 0 ||
as->streams[as->nb_streams - 1] >= s->nb_streams) {