diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2019-12-20 21:21:59 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-03-26 21:33:51 +0100 |
commit | 418e468699868a0265f8b439beedf64bb643b088 (patch) | |
tree | d820f4286bc54b76aba70c792de9013ff9beb32b | |
parent | 3875af84ed6f6c803aca961fc78400bcda021d44 (diff) | |
download | ffmpeg-418e468699868a0265f8b439beedf64bb643b088.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>
-rw-r--r-- | libavformat/webmdashenc.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c index 0e7bfba34c..d05b265330 100644 --- a/libavformat/webmdashenc.c +++ b/libavformat/webmdashenc.c @@ -488,11 +488,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) { |