diff options
author | Qball Cow <qball@blame.services> | 2024-02-29 00:00:36 +0100 |
---|---|---|
committer | Qball Cow <qball@blame.services> | 2024-02-29 00:00:36 +0100 |
commit | 42d6bb9af4aafa8d7147191fcc887d15c0ab46a4 (patch) | |
tree | 32fec67c841b02bf062a04a3fa668f97c9c03f70 | |
parent | afc65ac12565e5376c602156db76f6273423a538 (diff) |
[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.
-rw-r--r-- | source/modes/window.c | 12 |
1 files 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; } |