From 5603d0b8b94e15ed5af096173f65f625535540c9 Mon Sep 17 00:00:00 2001 From: night0721 Date: Thu, 26 Sep 2024 12:45:27 +0100 Subject: [PATCH] Resolve gcc warnings --- src/zen/ui.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/zen/ui.c b/src/zen/ui.c index 2212515..6524bc7 100644 --- a/src/zen/ui.c +++ b/src/zen/ui.c @@ -254,16 +254,18 @@ void draw_users() */ int too_long = 0; if (name_len > MAX_NAME / 2) { - name_len = MAX_NAME / 2; + /* Make space for truncation */ + name_len = MAX_NAME / 2 - 2; too_long = 1; } - char line[name_len]; + char line[name_len + 1]; if (too_long) { strncpy(line, seluser.name, (MAX_NAME / 2) - 2); - strncat(line, "..", 2); + strncat(line, "..", 3); } else { strncpy(line, seluser.name, name_len); + line[name_len] = '\0'; } int color = users->items[i].color;