summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorguikunzhi <guikunzhi@163.com>2018-04-26 12:40:52 +0800
committerSteven Liu <lq@chinaffmpeg.org>2018-04-26 12:40:52 +0800
commit8ea8be595166cdae73bf3f8bee2f28bc94f1c988 (patch)
treef0107eeee121a81130e296b26586fc6be1c7f363 /libavformat
parent1c97035e3b1677d6f0c5b6161ebfeffcf7bb638d (diff)
fix memory leak of parsing dash MPD
Signed-off-by: guikunzhi <guikunzhi@163.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/dashdec.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index a2e2e13382..c90bc51ce3 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -706,6 +706,7 @@ static int resolve_content_path(AVFormatContext *s, const char *url, int *max_ur
char *baseurl = NULL;
char *root_url = NULL;
char *text = NULL;
+ char *tmp = NULL;
int isRootHttp = 0;
char token ='/';
@@ -735,9 +736,11 @@ static int resolve_content_path(AVFormatContext *s, const char *url, int *max_ur
goto end;
}
av_strlcpy(text, url, strlen(url)+1);
- while (mpdName = av_strtok(text, "/", &text)) {
+ tmp = text;
+ while (mpdName = av_strtok(tmp, "/", &tmp)) {
size = strlen(mpdName);
}
+ av_free(text);
path = av_mallocz(tmp_max_url_size);
tmp_str = av_mallocz(tmp_max_url_size);
@@ -796,6 +799,7 @@ end:
}
av_free(path);
av_free(tmp_str);
+ xmlFree(baseurl);
return updated;
}
@@ -1121,6 +1125,7 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in)
xmlNodePtr root_element = NULL;
xmlNodePtr node = NULL;
xmlNodePtr period_node = NULL;
+ xmlNodePtr tmp_node = NULL;
xmlNodePtr mpd_baseurl_node = NULL;
xmlNodePtr period_baseurl_node = NULL;
xmlNodePtr period_segmenttemplate_node = NULL;
@@ -1215,8 +1220,10 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in)
xmlFree(val);
}
- mpd_baseurl_node = find_child_node_by_name(node, "BaseURL");
- if (!mpd_baseurl_node) {
+ tmp_node = find_child_node_by_name(node, "BaseURL");
+ if (tmp_node) {
+ mpd_baseurl_node = xmlCopyNode(tmp_node,1);
+ } else {
mpd_baseurl_node = xmlNewNode(NULL, "BaseURL");
}
@@ -1270,6 +1277,7 @@ cleanup:
/*free the document */
xmlFreeDoc(doc);
xmlCleanupParser();
+ xmlFreeNode(mpd_baseurl_node);
}
av_free(new_url);