From 13707013525364466ff226767f6c7a4997975369 Mon Sep 17 00:00:00 2001 From: ssouhlal Date: Fri, 3 Jun 2005 17:38:33 +0000 Subject: [PATCH] - Avoid a memory leak if realloc(3) fails by using reallocf(3) Submitted by: Liam J. Foy Approved by: mdodd (in-lieu of mentor who is away) MFC after: 1 week --- usr.sbin/rwhod/rwhod.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/usr.sbin/rwhod/rwhod.c b/usr.sbin/rwhod/rwhod.c index 4dbd03958cd3..96fd9ec42e58 100644 --- a/usr.sbin/rwhod/rwhod.c +++ b/usr.sbin/rwhod/rwhod.c @@ -410,11 +410,8 @@ onalrm(signo) utmptime = stb.st_mtime; if (stb.st_size > utmpsize) { utmpsize = stb.st_size + 10 * sizeof(struct utmp); - if (utmp) - utmp = (struct utmp *)realloc(utmp, utmpsize); - else - utmp = (struct utmp *)malloc(utmpsize); - if (! utmp) { + utmp = (struct utmp *)reallocf(utmp, utmpsize); + if (utmp == NULL) { syslog(LOG_WARNING, "malloc failed"); utmpsize = 0; goto done;