For some reason clang-15 doesn't like passing the uninitialized array of
pointers nargv[] to the vararg function tparm(). With -O2 it optimizes the
for loop preceding the tparm() call strangely, with the result that the
argv[i] == NULL error is hit in most real-world usage. This broke naddy's
fancy shell prompt among other things. Initialize nargv[] to appease the
insatiable undefined behavior exploiter.
ok jca millert
-/* $OpenBSD: tput.c,v 1.26 2022/12/22 19:53:24 kn Exp $ */
+/* $OpenBSD: tput.c,v 1.27 2023/02/03 15:55:59 tb Exp $ */
/*
* Copyright (c) 1999 Todd C. Miller <millert@openbsd.org>
static char **
process(char *cap, char *str, char **argv)
{
- char *cp, *s, *nargv[9];
+ char *cp, *s, *nargv[9] = {0};
int arg_need, popcount, i;
/* Count how many values we need for this capability. */