diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-09-07 18:14:47 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-02-27 07:20:59 +0100 |
commit | f3ee6b2a3e04624fcec0f230d4a429ff6cf0ea54 (patch) | |
tree | 2c60a26fbf3b4562e3a49a2b4babdacc9353f557 | |
parent | 3c13a44dd40f17264ac498d17cc15f237785ba20 (diff) | |
download | ffmpeg-f3ee6b2a3e04624fcec0f230d4a429ff6cf0ea54.tar.gz |
avformat/dashdec: Fix memleak on allocation error, avoid allocation
get_content_url() allocates two buffers for temporary strings and when
one of them couldn't be allocated, it simply returns, although one of
the two allocations could have succeeded and would leak in this
scenario. This can be fixed by avoiding one of the temporary buffers.
Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
(cherry picked from commit 0f9ade1ff395cfaf51f9a7ecc1ed725339aa1426)
-rw-r--r-- | libavformat/dashdec.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index afa74419d1..65f03e4a60 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -472,11 +472,9 @@ static char *get_content_url(xmlNodePtr *baseurl_nodes, char *text; char *url = NULL; char *tmp_str = av_mallocz(max_url_size); - char *tmp_str_2 = av_mallocz(max_url_size); - if (!tmp_str || !tmp_str_2) { + if (!tmp_str) return NULL; - } for (i = 0; i < n_baseurl_nodes; ++i) { if (baseurl_nodes[i] && @@ -485,9 +483,7 @@ static char *get_content_url(xmlNodePtr *baseurl_nodes, text = xmlNodeGetContent(baseurl_nodes[i]->children); if (text) { memset(tmp_str, 0, max_url_size); - memset(tmp_str_2, 0, max_url_size); - ff_make_absolute_url(tmp_str_2, max_url_size, tmp_str, text); - av_strlcpy(tmp_str, tmp_str_2, max_url_size); + ff_make_absolute_url(tmp_str, max_url_size, "", text); xmlFree(text); } } @@ -513,7 +509,6 @@ static char *get_content_url(xmlNodePtr *baseurl_nodes, } end: av_free(tmp_str); - av_free(tmp_str_2); return url; } |