From 9167d9255d2842ae59940fc80c92a707bc4e1905 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 5 Mar 2021 09:59:58 +0100 Subject: [PATCH] Work around weird finding from Coverity Scan The utmp_set() function allows id==NULL, so default the line to NULL and avoid parsing empty lines. Which is better code anyway. Signed-off-by: Joachim Wiberg --- src/utmp-api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utmp-api.c b/src/utmp-api.c index b70ea602..8ae9b680 100644 --- a/src/utmp-api.c +++ b/src/utmp-api.c @@ -194,13 +194,13 @@ static int set_getty(int type, char *tty, char *id, char *user) return 0; if (!tty) - line = ""; + line = NULL; else if (!strncmp(tty, "/dev/", 5)) line = tty + 5; else line = tty; - if (!id) { + if (!id && line) { id = line; if (!strncmp(id, "pts/", 4)) id += 4;