From 42d6bb9af4aafa8d7147191fcc887d15c0ab46a4 Mon Sep 17 00:00:00 2001 From: Qball Cow Date: Thu, 29 Feb 2024 00:00:36 +0100 Subject: [PATCH] [Window] write code so clang-check does not complain about leak. Does not solve the possible, but very unlikely leak, but keeps clang-check happy. --- source/modes/window.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/modes/window.c b/source/modes/window.c index 827abecd..27798c81 100644 --- a/source/modes/window.c +++ b/source/modes/window.c @@ -176,7 +176,7 @@ static winlist *winlist_new(void) { * * Add one entry. If Full, extend with WINLIST entries. * - * @returns 0 if failed, 1 is successful. + * @returns -1 if failed, 0 or higher is successful. */ static int winlist_append(winlist *l, xcb_window_t w, client *d) { if (l->len > 0 && !(l->len % WINLIST)) { @@ -187,7 +187,7 @@ static int winlist_append(winlist *l, xcb_window_t w, client *d) { // Make clang-check happy. // TODO: make clang-check clear this should never be 0. if (l->data == NULL || l->array == NULL) { - return 0; + return -1; } l->data[l->len] = d; @@ -386,7 +386,13 @@ static client *window_client(WindowModePrivateData *pd, xcb_window_t win) { c->hint_flags = r.flags; } - winlist_append(cache_client, c->window, c); + idx = winlist_append(cache_client, c->window, c); + // Should never happen. + if (idx < 0) { + client_free(c); + g_free(c); + c = NULL; + } g_free(attr); return c; }