mirror of
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git
synced 2026-01-26 14:13:24 +00:00
color: handle case where fmt is NULL
There are cases where NULL is passed as format string when nothing is to be printed. This is commonly done in the print_bool function when a flag is false. Glibc seems to handle this case nicely but for musl it will cause a segmentation fault Since nothing needs to be printed, in this case; just check for NULL and return. Reported-by: Pedro Tammela <pctammela@mojatatu.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
parent
325c96e749
commit
da5a2d94dc
@ -140,6 +140,9 @@ int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
|
if (fmt == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
|
||||||
if (!color_is_enabled || attr == COLOR_NONE) {
|
if (!color_is_enabled || attr == COLOR_NONE) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user