forked from external/yambar
module/i3-common: always disconnect from XCB on error
This commit is contained in:
parent
37d15096f9
commit
76dc4f82cd
1 changed files with 9 additions and 7 deletions
|
@ -37,15 +37,14 @@ get_socket_address_x11(struct sockaddr_un *addr)
|
||||||
conn, false, screen->root, atom,
|
conn, false, screen->root, atom,
|
||||||
XCB_GET_PROPERTY_TYPE_ANY, 0, sizeof(addr->sun_path));
|
XCB_GET_PROPERTY_TYPE_ANY, 0, sizeof(addr->sun_path));
|
||||||
|
|
||||||
xcb_generic_error_t *err;
|
xcb_generic_error_t *err = NULL;
|
||||||
xcb_get_property_reply_t *reply =
|
xcb_get_property_reply_t *reply =
|
||||||
xcb_get_property_reply(conn, cookie, &err);
|
xcb_get_property_reply(conn, cookie, &err);
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
LOG_ERR("failed to get i3 socket path: %s", xcb_error(err));
|
LOG_ERR("failed to get i3 socket path: %s", xcb_error(err));
|
||||||
free(err);
|
goto err;
|
||||||
free(reply);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const int len = xcb_get_property_value_length(reply);
|
const int len = xcb_get_property_value_length(reply);
|
||||||
|
@ -53,16 +52,19 @@ get_socket_address_x11(struct sockaddr_un *addr)
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
LOG_ERR("failed to get i3 socket path: empty reply");
|
LOG_ERR("failed to get i3 socket path: empty reply");
|
||||||
free(reply);
|
goto err;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(addr->sun_path, xcb_get_property_value(reply), len);
|
memcpy(addr->sun_path, xcb_get_property_value(reply), len);
|
||||||
addr->sun_path[len] = '\0';
|
addr->sun_path[len] = '\0';
|
||||||
|
|
||||||
|
ret = true;
|
||||||
|
|
||||||
|
err:
|
||||||
|
free(err);
|
||||||
free(reply);
|
free(reply);
|
||||||
xcb_disconnect(conn);
|
xcb_disconnect(conn);
|
||||||
return true;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue