From fb56799357b01dec7cfe37d33f95cb02962814e9 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 4 Apr 2015 16:17:29 +0200 Subject: [PATCH] Correctly handle calloc() failure If an extension that we support is not present in the X11 server, this is not a fatal error. We can just skip this extension. However, the code implementing this accidentally also made calloc()-failures non-fatal which is wrong. Spotted by Ran Benita. Signed-off-by: Uli Schlachter --- src/xcb_errors.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xcb_errors.c b/src/xcb_errors.c index 25b42d4..c6f87d4 100644 --- a/src/xcb_errors.c +++ b/src/xcb_errors.c @@ -58,12 +58,12 @@ int register_extension(xcb_errors_context_t *ctx, xcb_connection_t *conn, reply = xcb_query_extension_reply(conn, cookie, NULL); if (!info || !reply || !reply->present) { - int had_error = !reply || reply->present; + int not_present = reply && !reply->present; free(info); free(reply); - if (had_error) - return -1; - return 0; + if (not_present) + return 0; + return -1; } info->name = name;