lib/colors.c: In function 'colors_read_schemes':
lib/colors.c:412:7: warning: potential null pointer dereference [-Wnull-dereference]
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
static int cn_sequence(const char *str, char **seq)
{
char *in, *out;
+ int len;
if (!str)
return -EINVAL;
}
/* 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++) {
}
in++;
}
+
+ assert ((out - *seq) <= len);
*out = '\0';
return 0;