X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Futmp-wtmp.c;h=45da79c681c8e3d92bf1abf2db75630593462ae6;hp=5aafb7b722272b411c051746a2bc834f64e0475f;hb=319346674c5665af895e854e1754eed4b5e36f42;hpb=ef2f1067d0ca0e6d7346aa3e082048821b670b54 diff --git a/src/utmp-wtmp.c b/src/utmp-wtmp.c index 5aafb7b72..45da79c68 100644 --- a/src/utmp-wtmp.c +++ b/src/utmp-wtmp.c @@ -291,17 +291,19 @@ finish: int utmp_wall(const char *message) { struct utmpx *u; char date[26]; - char *text, *hn, *un, *tty; + char *text = NULL, *hn = NULL, *un = NULL, *tty = NULL; int r; time_t t; if (!(hn = gethostname_malloc()) || - !(un = getlogname_malloc()) || - !(tty = getttyname_malloc())) { + !(un = getlogname_malloc())) { r = -ENOMEM; goto finish; } + if ((r = getttyname_malloc(&tty)) < 0) + goto finish; + time(&t); assert_se(ctime_r(&t, date)); delete_chars(date, "\n\r");