From d29d908003b0acb0fa9fa0e9618186931423a20e Mon Sep 17 00:00:00 2001 From: Theo Buehler Date: Wed, 23 Aug 2017 15:48:58 +0200 Subject: [PATCH] Avoid use of uninitialized in init_dpi_end If conn == NULL or display == NULL, init_dpi() jumps to init_dpi_end before (declaring and) initializing resource. In init_dpi_end, there is a free(resource) call conditionally on resource != NULL, so this may lead to a bogus free. Found by clang -Wsometimes-uninitialized. --- libi3/dpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libi3/dpi.c b/libi3/dpi.c index ce85cacc..93a3c6f6 100644 --- a/libi3/dpi.c +++ b/libi3/dpi.c @@ -24,6 +24,7 @@ static long init_dpi_fallback(void) { */ void init_dpi(void) { xcb_xrm_database_t *database = NULL; + char *resource = NULL; if (conn == NULL) { goto init_dpi_end; @@ -35,7 +36,6 @@ void init_dpi(void) { goto init_dpi_end; } - char *resource; xcb_xrm_resource_get_string(database, "Xft.dpi", NULL, &resource); if (resource == NULL) { DLOG("Resource Xft.dpi not specified, skipping.\n");