[FFmpeg-devel] [Patch] Fix for ticket 6658 (Dash demuxer segfault)

Moritz Barsnick barsnick at gmx.net
Sun Nov 19 16:12:27 EET 2017


On Sat, Nov 18, 2017 at 00:16:33 +0000, Colin NG wrote:
> Cleaned the code up.

Please do read the ffmpeg style guide.

> +static char * ishttp(char *url) {

Asterisk attaches to the right hand side.

> -    ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp);
> +    av_freep(pb);
> +    ret = avio_open2(pb, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp);
> +
>      if (ret >= 0) {

No reason to introduce an exta empty line.

> +static int resolve_content_path(AVFormatContext *s, const char *url,  xmlNodePtr *baseurl_nodes,  int n_baseurl_nodes) {

Opening curly bracket for functions goes on a new line.

> +    av_strlcpy(tmp_str, url, strlen(url)+1);

Operators get spaces around them.

> +    char *mpdName = strtok (tmp_str," /");

Space after comma.

> +    while ((mpdName =strtok (NULL, "/"))) {

Operators get spaces around them.

> +    av_strlcpy (path, url, strlen(url)-nameSize+1);

No space before opening bracket (except for if, while, ...).
Operators get spaces around them.

> +    xmlNodePtr  *node = NULL;

Too much whitespace.

> +    for (rootId = n_baseurl_nodes-1; rootId >0; rootId--) {

Operators get spaces around them.

> +        if (!(node = baseurl_nodes[rootId])) continue;

Newline. Preferably with {}.

> +    char *root_url = (!av_strcasecmp(baseurl, ""))? path: baseurl;

Operators get spaces around them.

> +    char *isRootHttp= ishttp(root_url);

Operators get spaces around them.

> +    char token ='/';

Operators get spaces around them.

> +    if (strncmp(&root_url[size-1],&token, 1) != 0) {

Operators get spaces around them.
Spaces after commas.

> +        size+=2;

Operators get spaces around them.

> +    for (i = 0; i < n_baseurl_nodes; ++i) {

i++

> +        if (i==rootId) continue;

Newline. Preferably with {}.

> +                av_strlcpy(tmp_str, root_url, size+1);

Operators get spaces around them.

Moritz


More information about the ffmpeg-devel mailing list