diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-08-25 13:53:37 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2012-08-29 22:00:55 -0700 |
commit | ff53285ae3f604e9f2cc5f4837255220459b5e44 (patch) | |
tree | 1d6a959cc46f71355b22bdfb42bf460e83ff83c6 /src/xcb_util.c | |
parent | 90889794ad882a6847bcffe52c4cc5dfd168f1f4 (diff) |
Return connection failure if display string specifies non-existent screen
Matches the behaviour of Xlib - if you set DISPLAY to :0.1 but only have
one screen, closes connection and returns error.
This introduces a new connection error code:
XCB_CONN_CLOSED_INVALID_SCREEN
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'src/xcb_util.c')
-rw-r--r-- | src/xcb_util.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/xcb_util.c b/src/xcb_util.c index e480d75..463d085 100644 --- a/src/xcb_util.c +++ b/src/xcb_util.c @@ -467,6 +467,16 @@ xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *displayname, else c = xcb_connect_to_fd(fd, 0); + if(c->has_error) + goto out; + + /* Make sure requested screen number is in bounds for this server */ + if((screenp != NULL) && (*screenp >= (int) c->setup->roots_len)) { + xcb_disconnect(c); + c = _xcb_conn_ret_error(XCB_CONN_CLOSED_INVALID_SCREEN); + goto out; + } + out: free(host); free(protocol); |