diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 5909677bf1..3e5a39c781 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -734,7 +734,7 @@ static int resolve_content_path(AVFormatContext *s, const char *url, int *max_ur } tmp_max_url_size = aligned(tmp_max_url_size); - text = av_mallocz(tmp_max_url_size); + text = av_mallocz(tmp_max_url_size + 1); if (!text) { updated = AVERROR(ENOMEM); goto end; @@ -746,7 +746,7 @@ static int resolve_content_path(AVFormatContext *s, const char *url, int *max_ur } av_free(text); - path = av_mallocz(tmp_max_url_size); + path = av_mallocz(tmp_max_url_size + 2); tmp_str = av_mallocz(tmp_max_url_size); if (!tmp_str || !path) { updated = AVERROR(ENOMEM); @@ -768,6 +768,15 @@ static int resolve_content_path(AVFormatContext *s, const char *url, int *max_ur node = baseurl_nodes[rootId]; baseurl = xmlNodeGetContent(node); + if (baseurl) { + size_t len = xmlStrlen(baseurl)+2; + char *tmp = xmlRealloc(baseurl, len); + if (!tmp) { + updated = AVERROR(ENOMEM); + goto end; + } + baseurl = tmp; + } root_url = (av_strcasecmp(baseurl, "")) ? baseurl : path; if (node) { xmlNodeSetContent(node, root_url);