From 828f6506b488a67d26ea8b7c50042a505c450b79 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 29 Apr 2024 15:25:58 +0200
Subject: [PATCH] wall: fix possible memory leak

Signed-off-by: Karel Zak <kzak@redhat.com>
---
 term-utils/wall.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/term-utils/wall.c b/term-utils/wall.c
index 1e7e9ab..cc39bdc 100644
--- a/term-utils/wall.c
+++ b/term-utils/wall.c
@@ -284,10 +284,10 @@ static char *makemsg(char *fname, char **mvec, int mvecsz,
 
 	if (print_banner == TRUE) {
 		char *hostname = xgethostname();
-		char *whom, *where, date[CTIME_BUFSIZ];
+		char *whombuf, *whom, *where, date[CTIME_BUFSIZ];
 		time_t now;
 
-		whom = xgetlogin();
+		whombuf = whom = xgetlogin();
 		if (!whom) {
 			whom = "<someone>";
 			warn(_("cannot get passwd uid"));
@@ -318,6 +318,7 @@ static char *makemsg(char *fname, char **mvec, int mvecsz,
 				whom, hostname, where, date);
 		fprintf(fs, "%-*.*s\007\007\r\n", TERM_WIDTH, TERM_WIDTH, lbuf);
 		free(hostname);
+		free(whombuf);
 	}
 	fprintf(fs, "%*s\r\n", TERM_WIDTH, " ");
 
-- 
2.43.0

