On Sun, Mar 05, 2017 at 08:52:32PM +0000, Sami Kerola wrote: > lib/colors.c: In function 'colors_read_schemes': > lib/colors.c:412:7: warning: potential null pointer dereference [-Wnull-dereference] > *out = '\0'; > ~~~~~^~~~~~ > > Signed-off-by: Sami Kerola <kerolasa@xxxxxx> > --- > lib/colors.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/lib/colors.c b/lib/colors.c > index 4b280fe27..baafe0a90 100644 > --- a/lib/colors.c > +++ b/lib/colors.c > @@ -342,6 +342,7 @@ static char *colors_get_homedir(char *buf, size_t bufsz) > static int cn_sequence(const char *str, char **seq) > { > char *in, *out; > + int len; > > if (!str) > return -EINVAL; > @@ -357,7 +358,7 @@ static int cn_sequence(const char *str, char **seq) > } > > /* convert xx;yy sequences to "\033[xx;yy" */ > - if (asprintf(seq, "\033[%sm", str) < 1) > + if ((len = asprintf(seq, "\033[%sm", str)) < 1) > return -ENOMEM; > > for (in = *seq, out = *seq; in && *in; in++) { > @@ -409,6 +410,7 @@ static int cn_sequence(const char *str, char **seq) > } > in++; > } > + assert (len < (out - *seq)); This seems incorrect. Should be: assert ((out - *seq) <= len); note that asprintf() returns size without terminating byte. Hmm.. we have no test_colors used in our regression tests. Simple test: $ echo 'mybell \a' > ~/.config/terminal-colors.d/foo.scheme $ TERMINAL_COLORS_DEBUG=all ./test_colors --name foo --color-scheme mybell Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html