From 234d7aa97f17ff02b9bfe3a3ad29e42227fe15ea Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Wed, 4 Aug 2010 21:05:21 -0400 Subject: [PATCH] [main] Properly handle no serial consoles The previous commit introduced an error where console could potentially be accessed while NULL. This commit addresses that problem. --- src/main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main.c b/src/main.c index 089f4c4d..94c0d321 100644 --- a/src/main.c +++ b/src/main.c @@ -1760,11 +1760,15 @@ check_for_consoles (state_t *state, } free (state->kernel_console_tty); + state->kernel_console_tty = NULL; - if (strcmp (console, "tty0") == 0 || strcmp (console, "/dev/tty0") == 0) - state->kernel_console_tty = strdup (default_tty); - else - state->kernel_console_tty = strdup (console); + if (console != NULL) + { + if (strcmp (console, "tty0") == 0 || strcmp (console, "/dev/tty0") == 0) + state->kernel_console_tty = strdup (default_tty); + else + state->kernel_console_tty = strdup (console); + } if (should_add_displays) { -- 2.47.3