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)
This commit is contained in:
David du Colombier 2023-09-30 22:32:17 +02:00
parent c26eaf6bc5
commit d3b212ad29
1 changed files with 2 additions and 0 deletions

View File

@ -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;