- 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:
parent
510d072f72
commit
1370701352
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user