- Avoid a memory leak if realloc(3) fails by using reallocf(3)

Submitted by:	Liam J. Foy <liamfoy@dragonflybsd.org>
Approved by:	mdodd (in-lieu of mentor who is away)
MFC after:	1 week
This commit is contained in:
Suleiman Souhlal 2005-06-03 17:38:33 +00:00
parent b297022008
commit 83eb8428e2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=146940

View File

@ -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;