diff mbox series

[FFmpeg-devel,01/11] avformat/webmdashenc: Fix segfault when no filename is given when live

Message ID 20200718000636.2167-1-andreas.rheinhardt@gmail.com
State Accepted
Commit c1fab8637e4bd9e0f09ae31247b709a22dafa440
Headers show
Series [FFmpeg-devel,01/11] avformat/webmdashenc: Fix segfault when no filename is given when live
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt July 18, 2020, 12:06 a.m. UTC
by checking a bit earlier.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/webmdashenc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Andreas Rheinhardt July 24, 2020, 1:16 a.m. UTC | #1
Andreas Rheinhardt:
> by checking a bit earlier.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/webmdashenc.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
> index eb286cab99..3eefd6df8b 100644
> --- a/libavformat/webmdashenc.c
> +++ b/libavformat/webmdashenc.c
> @@ -171,8 +171,7 @@ static int write_representation(AVFormatContext *s, AVStream *stream, char *id,
>      AVDictionaryEntry *filename = av_dict_get(stream->metadata, FILENAME, NULL, 0);
>      AVDictionaryEntry *bandwidth = av_dict_get(stream->metadata, BANDWIDTH, NULL, 0);
>      const char *bandwidth_str;
> -    if ((w->is_live && (!filename)) ||
> -        (!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth))) {
> +    if (!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth)) {
>          return AVERROR_INVALIDDATA;
>      }
>      avio_printf(s->pb, "<Representation id=\"%s\"", id);
> @@ -380,7 +379,10 @@ static int write_adaptation_set(AVFormatContext *s, int as_index)
>              av_dict_get(s->streams[as->streams[0]]->metadata, FILENAME, NULL, 0);
>          char *initialization_pattern = NULL;
>          char *media_pattern = NULL;
> -        int ret = parse_filename(filename->value, NULL, &initialization_pattern,
> +        int ret;
> +        if (!filename)
> +            return AVERROR(EINVAL);
> +        ret = parse_filename(filename->value, NULL, &initialization_pattern,
>                                   &media_pattern);
>          if (ret) return ret;
>          avio_printf(s->pb, "<ContentComponent id=\"1\" type=\"%s\"/>\n",
> 

Will apply this patchset tomorrow unless there are objections.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index eb286cab99..3eefd6df8b 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -171,8 +171,7 @@  static int write_representation(AVFormatContext *s, AVStream *stream, char *id,
     AVDictionaryEntry *filename = av_dict_get(stream->metadata, FILENAME, NULL, 0);
     AVDictionaryEntry *bandwidth = av_dict_get(stream->metadata, BANDWIDTH, NULL, 0);
     const char *bandwidth_str;
-    if ((w->is_live && (!filename)) ||
-        (!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth))) {
+    if (!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth)) {
         return AVERROR_INVALIDDATA;
     }
     avio_printf(s->pb, "<Representation id=\"%s\"", id);
@@ -380,7 +379,10 @@  static int write_adaptation_set(AVFormatContext *s, int as_index)
             av_dict_get(s->streams[as->streams[0]]->metadata, FILENAME, NULL, 0);
         char *initialization_pattern = NULL;
         char *media_pattern = NULL;
-        int ret = parse_filename(filename->value, NULL, &initialization_pattern,
+        int ret;
+        if (!filename)
+            return AVERROR(EINVAL);
+        ret = parse_filename(filename->value, NULL, &initialization_pattern,
                                  &media_pattern);
         if (ret) return ret;
         avio_printf(s->pb, "<ContentComponent id=\"1\" type=\"%s\"/>\n",