Merge commit '2c3f29c4894ee50635b846f202296ad79a7c0d33'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 10 Dec 2014 11:20:23 +0000 (12:20 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 10 Dec 2014 11:33:37 +0000 (12:33 +0100)
* commit '2c3f29c4894ee50635b846f202296ad79a7c0d33':
  xcbgrab: Support empty filename string correctly

Conflicts:
libavdevice/xcbgrab.c

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

@@@ -603,21 -593,11 +603,21 @@@ static av_cold int xcbgrab_read_header(
      XCBGrabContext *c = s->priv_data;
      int screen_num, ret;
      const xcb_setup_t *setup;
 +    char *display_name = av_strdup(s->filename);
  
 -    c->conn = xcb_connect(s->filename[0] ? s->filename : NULL, &screen_num);
 +    if (!display_name)
 +        return AVERROR(ENOMEM);
 +
 +    if (!sscanf(s->filename, "%[^+]+%d,%d", display_name, &c->x, &c->y)) {
 +        *display_name = 0;
 +        sscanf(s->filename, "+%d,%d", &c->x, &c->y);
 +    }
 +
-     c->conn = xcb_connect(display_name, &screen_num);
++    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) ? s->filename : "default", ret);
+                s->filename[0] ? s->filename : "default", ret);
          return AVERROR(EIO);
      }
      setup = xcb_get_setup(c->conn);