From: Karel Zak Date: Mon, 29 Apr 2024 13:25:58 +0000 (+0200) Subject: wall: fix possible memory leak X-Git-Tag: v2.42-start~364 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=828f6506b488a67d26ea8b7c50042a505c450b79;p=thirdparty%2Futil-linux.git wall: fix possible memory leak Signed-off-by: Karel Zak --- diff --git a/term-utils/wall.c b/term-utils/wall.c index 588d3a963..4937bdc80 100644 --- a/term-utils/wall.c +++ b/term-utils/wall.c @@ -324,10 +324,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 = ""; warn(_("cannot get passwd uid")); @@ -358,6 +358,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, " ");