From d0b170c8133d0c155b18aabef919693dcba406dd Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Jun 2010 23:13:15 +0200 Subject: [PATCH] main: don't segfault when --log-color is passed without parameter --- src/main.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index 8a7f18ea..21b4174a 100644 --- a/src/main.c +++ b/src/main.c @@ -412,19 +412,25 @@ static int parse_argv(int argc, char *argv[]) { case ARG_LOG_COLOR: - if ((r = log_show_color_from_string(optarg)) < 0) { - log_error("Failed to parse log color setting %s.", optarg); - return r; - } + if (optarg) { + if ((r = log_show_color_from_string(optarg)) < 0) { + log_error("Failed to parse log color setting %s.", optarg); + return r; + } + } else + log_show_color(true); break; case ARG_LOG_LOCATION: - if ((r = log_show_location_from_string(optarg)) < 0) { - log_error("Failed to parse log location setting %s.", optarg); - return r; - } + if (optarg) { + if ((r = log_show_location_from_string(optarg)) < 0) { + log_error("Failed to parse log location setting %s.", optarg); + return r; + } + } else + log_show_location(true); break; -- 2.39.5