Don't forget to catch realloc() errors.
This commit is contained in:
parent
aacd7d6afc
commit
6d2b7c381b
@ -88,9 +88,12 @@ main(int argc, char *argv[])
|
|||||||
while ((u = getutxent()) != NULL) {
|
while ((u = getutxent()) != NULL) {
|
||||||
if (u->ut_type != USER_PROCESS)
|
if (u->ut_type != USER_PROCESS)
|
||||||
continue;
|
continue;
|
||||||
if ((ulistsize % 16) == 0)
|
if ((ulistsize % 16) == 0) {
|
||||||
ulist = realloc(ulist,
|
ulist = realloc(ulist,
|
||||||
(ulistsize + 16) * sizeof(struct utmpx));
|
(ulistsize + 16) * sizeof(struct utmpx));
|
||||||
|
if (ulist == NULL)
|
||||||
|
err(1, "malloc");
|
||||||
|
}
|
||||||
ulist[ulistsize++] = *u;
|
ulist[ulistsize++] = *u;
|
||||||
}
|
}
|
||||||
endutxent();
|
endutxent();
|
||||||
|
Loading…
Reference in New Issue
Block a user