summaryrefslogtreecommitdiff
path: root/libavformat/dashdec.c
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-02-04 09:33:17 +0800
committerSteven Liu <liuqi05@kuaishou.com>2021-02-04 10:30:39 +0800
commita44c42dc31333968650382a640480cedc3c9ae3c (patch)
tree881c78d3eaff8f71be56003d69b63a6cef6a84ed /libavformat/dashdec.c
parent5a98a027d6b4e21d8ada0b94ad81226b35c21446 (diff)
avformat/dashdec: Avoid segfault when URL template is unexpectedly missing
This isn't supposed to happen, but unfinished support for non-templated manifests and lack of e.g. presentationTimeOffset handling can provoke such a situation even with well-formed input.
Diffstat (limited to 'libavformat/dashdec.c')
-rw-r--r--libavformat/dashdec.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 04dbdb668e..b82805c9ce 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1626,8 +1626,15 @@ static struct fragment *get_current_fragment(struct representation *pls)
}
}
if (seg) {
- char *tmpfilename= av_mallocz(c->max_url_size);
+ char *tmpfilename;
+ if (!pls->url_template) {
+ av_log(pls->parent, AV_LOG_ERROR, "Cannot get fragment, missing template URL\n");
+ av_free(seg);
+ return NULL;
+ }
+ tmpfilename = av_mallocz(c->max_url_size);
if (!tmpfilename) {
+ av_free(seg);
return NULL;
}
ff_dash_fill_tmpl_params(tmpfilename, c->max_url_size, pls->url_template, 0, pls->cur_seq_no, 0, get_segment_start_time_based_on_timeline(pls, pls->cur_seq_no));
@@ -1638,6 +1645,7 @@ static struct fragment *get_current_fragment(struct representation *pls)
if (!seg->url) {
av_log(pls->parent, AV_LOG_ERROR, "Cannot resolve template url '%s'\n", pls->url_template);
av_free(tmpfilename);
+ av_free(seg);
return NULL;
}
}