debug.c: fix no-color-printing in case .color = NULL

This commit is contained in:
Harald Welte 2010-03-26 09:45:03 +08:00
parent 4a2bb9e38b
commit d788f6688c
1 changed files with 6 additions and 3 deletions

View File

@ -115,7 +115,7 @@ static const char* color(int subsys)
return debug_info->cat[i].color;
}
return "";
return NULL;
}
static void _output(struct debug_target *target, unsigned int subsys,
@ -136,8 +136,11 @@ static void _output(struct debug_target *target, unsigned int subsys,
/* are we using color */
if (target->use_color) {
snprintf(col, sizeof(col), "%s", color(subsys));
col[sizeof(col)-1] = '\0';
const char *c = color(subsys);
if (c) {
snprintf(col, sizeof(col), "%s", color(subsys));
col[sizeof(col)-1] = '\0';
}
}
vsnprintf(buf, sizeof(buf), format, ap);
buf[sizeof(buf)-1] = '\0';