diff mbox

[FFmpeg-devel] Download dash content with byte range info

Message ID DM5PR22MB0681A8ECAC09C54F37130B7DFE290@DM5PR22MB0681.namprd22.prod.outlook.com
State Superseded
Headers show

Commit Message

Colin NG Nov. 15, 2017, 9 p.m. UTC
This patch is partial fix for ticket 6658 (Dash demuxer segfault).

Comments

Carl Eugen Hoyos Nov. 15, 2017, 10:37 p.m. UTC | #1
2017-11-15 22:00 GMT+01:00 Colin NG <colin_ng@hotmail.com>:
> This patch is partial fix for ticket 6658 (Dash demuxer segfault).

> +static struct fragment * get_Fragment(char *range) {
> +    struct fragment * seg =  av_mallocz(sizeof(struct fragment));

Please make it (code-style):
... fragment *get_Fragment...
... fragment *seg =...

> +    if (!seg)
> +        goto finish;

No.

You can "return NULL;" but since this is a little misleading,
it may be better to return AVERROR(ENOMEM) and instead
of the existing check for NULL below, check for "< 0".

Carl Eugen
diff mbox

Patch

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 0e3afd2..68196e9 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -522,6 +522,22 @@  static enum AVMediaType get_content_type(xmlNodePtr node)
     return type;
 }

+static struct fragment * getFragment(char *range)
Camel-Case code style, please use name looks like : get_fragment

+{
+    struct fragment * seg =  av_mallocz(sizeof(struct fragment));
check the seg , if av_mallocz is failed, it will error;
+
+    memset(seg, 0, sizeof(struct fragment));
unnecessary memset, because av_mallocz is set seg to 0 already.

+    seg->size = -1;
+    if (range)  {
+        char *str_end_offset;
+        char *str_offset = av_strtok(range, "-", &str_end_offset);
+        seg->url_offset = strtoll(str_offset, NULL, 10);
+        seg->size = strtoll(str_end_offset, NULL, 10) -seg->url_offset;
+    }
+
+    return seg;