Merge commit '85b3b1c4ba7af9c2658442b0aafd27d613e1854b'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 25 Feb 2015 00:33:18 +0000 (01:33 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 25 Feb 2015 00:44:49 +0000 (01:44 +0100)
* commit '85b3b1c4ba7af9c2658442b0aafd27d613e1854b':
  xcbgrab: Unbreak parsing filename options

Conflicts:
libavdevice/xcbgrab.c

See: db442c873631065e8719df6da91c016d25501084
Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavdevice/xcbgrab.c

@@@ -603,21 -596,23 +603,22 @@@ static av_cold int xcbgrab_read_header(
      XCBGrabContext *c = s->priv_data;
      int screen_num, ret;
      const xcb_setup_t *setup;
 -    char *host        = s->filename[0] ? s->filename : NULL;
 -    const char *opts  = strchr(s->filename, '+');
 +    char *display_name = av_strdup(s->filename);
  
 -    if (opts) {
 -        sscanf(opts, "%d,%d", &c->x, &c->y);
 -        host = av_strdup(s->filename);
 -        host[opts - s->filename] = '\0';
 -    }
 +    if (!display_name)
 +        return AVERROR(ENOMEM);
  
 -    c->conn = xcb_connect(host, &screen_num);
 +    if (!sscanf(s->filename, "%[^+]+%d,%d", display_name, &c->x, &c->y)) {
 +        *display_name = 0;
 +        sscanf(s->filename, "+%d,%d", &c->x, &c->y);
 +    }
  
 -    if (opts)
 -        av_free(host);
 +    c->conn = xcb_connect(display_name[0] ? display_name : NULL, &screen_num);
 +    av_freep(&display_name);
      if ((ret = xcb_connection_has_error(c->conn))) {
          av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
 -               s->filename[0] ? host : "default", ret);
 +               s->filename[0] ? s->filename : "default", ret);
          return AVERROR(EIO);
      }
      setup = xcb_get_setup(c->conn);