i3test::XTEST: free errors and connections with errors

This commit is contained in:
Michael Stapelberg 2016-01-09 12:41:02 +01:00
parent 9dde0b9b18
commit f3a5796a8b
1 changed files with 6 additions and 0 deletions

View File

@ -59,6 +59,9 @@ bool inlinec_connect() {
if ((conn = xcb_connect(NULL, &screen)) == NULL || if ((conn = xcb_connect(NULL, &screen)) == NULL ||
xcb_connection_has_error(conn)) { xcb_connection_has_error(conn)) {
if (conn != NULL) {
xcb_disconnect(conn);
}
fprintf(stderr, "Could not connect to X11\n"); fprintf(stderr, "Could not connect to X11\n");
return false; return false;
} }
@ -79,6 +82,7 @@ bool inlinec_connect() {
conn, xcb_xkb_use_extension(conn, XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION), &err); conn, xcb_xkb_use_extension(conn, XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION), &err);
if (err != NULL || usereply == NULL) { if (err != NULL || usereply == NULL) {
fprintf(stderr, "xcb_xkb_use_extension() failed\n"); fprintf(stderr, "xcb_xkb_use_extension() failed\n");
free(err);
return false; return false;
} }
free(usereply); free(usereply);
@ -104,6 +108,7 @@ bool set_xkb_group(int group) {
0); /* groupLatch */ 0); /* groupLatch */
if ((err = xcb_request_check(conn, cookie)) != NULL) { if ((err = xcb_request_check(conn, cookie)) != NULL) {
fprintf(stderr, "X error code %d\n", err->error_code); fprintf(stderr, "X error code %d\n", err->error_code);
free(err);
return false; return false;
} }
return true; return true;
@ -124,6 +129,7 @@ bool xtest_input(int type, int detail, int x, int y) {
XCB_NONE); /* deviceid */ XCB_NONE); /* deviceid */
if ((err = xcb_request_check(conn, cookie)) != NULL) { if ((err = xcb_request_check(conn, cookie)) != NULL) {
fprintf(stderr, "X error code %d\n", err->error_code); fprintf(stderr, "X error code %d\n", err->error_code);
free(err);
return false; return false;
} }