From d3b212ad297d32bce0c9be38213fa5c67b2530a9 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 30 Sep 2023 22:32:17 +0200 Subject: [PATCH] lib/libstuff/x11/colors: fix initialization of CTuple in loadcolor This error was reported by Valgrind: ==237870== Conditional jump or move depends on uninitialised value(s) ==237870== at 0x484AF0E: bcmp (vg_replace_strmem.c:1221) ==237870== by 0x40C9DB: update_imgs (div.c:117) ==237870== by 0x40CB4C: div_update_all (div.c:138) ==237870== by 0x420A0F: view_arrange (view.c:611) ==237870== by 0x41F88C: view_update (view.c:337) ==237870== by 0x418B59: message_root (message.c:686) ==237870== by 0x42474D: ixp_srv_writectl (srv_util.c:232) ==237870== by 0x41322E: fs_write (fs.c:513) ==237870== by 0x423462: handlereq (request.c:321) ==237870== by 0x422BFF: handlefcall (request.c:146) ==237870== by 0x4240E8: handle_conns (server.c:118) ==237870== by 0x42424C: ixp_serverloop (server.c:169) --- lib/libstuff/x11/colors/loadcolor.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/libstuff/x11/colors/loadcolor.c b/lib/libstuff/x11/colors/loadcolor.c index 70fadb33..769d4f7f 100644 --- a/lib/libstuff/x11/colors/loadcolor.c +++ b/lib/libstuff/x11/colors/loadcolor.c @@ -9,6 +9,8 @@ loadcolor(CTuple *c, const char *str, const char *end) { char buf[128]; char *toks[4]; + memset(c, 0, sizeof(*c)); + utflcpy(buf, str, end ? min(end - str + 1, sizeof buf) : sizeof buf); if(3 > stokenize(toks, nelem(toks), buf, " \t\r\n")) return 0;