mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
- 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
b297022008
commit
83eb8428e2
1 changed files with 2 additions and 5 deletions
|
|
@ -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 a new issue