From: Sami Kerola Date: Sun, 7 Jul 2013 19:54:43 +0000 (+0100) Subject: sulogin: fix memory leak [clang-analyzer] X-Git-Tag: v2.24-rc1~434 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=21c4058d92f5f17b87c62063eb77d126be08bd0e;p=thirdparty%2Futil-linux.git sulogin: fix memory leak [clang-analyzer] And make code a little bit more robust. Signed-off-by: Sami Kerola --- diff --git a/login-utils/sulogin-consoles.c b/login-utils/sulogin-consoles.c index d0f0eab2be..a131e79742 100644 --- a/login-utils/sulogin-consoles.c +++ b/login-utils/sulogin-consoles.c @@ -719,7 +719,7 @@ console: fallback: if (fallback >= 0) { - const char *name; + const char *name, *n; struct console *console; if (device && *device != '\0') @@ -729,7 +729,11 @@ fallback: if (!name) name = "/dev/tty"; - rc = append_console(consoles, strdup(name)); + n = strdup(name); + if (!n) + return -ENOMEM; + rc = append_console(consoles, n); + free(n); if (rc < 0) return rc; if (list_empty(consoles))