Don't forget to catch realloc() errors.

This commit is contained in:
Ed Schouten 2010-04-11 12:07:03 +00:00
parent aacd7d6afc
commit 6d2b7c381b

View File

@ -88,9 +88,12 @@ main(int argc, char *argv[])
while ((u = getutxent()) != NULL) {
if (u->ut_type != USER_PROCESS)
continue;
if ((ulistsize % 16) == 0)
if ((ulistsize % 16) == 0) {
ulist = realloc(ulist,
(ulistsize + 16) * sizeof(struct utmpx));
if (ulist == NULL)
err(1, "malloc");
}
ulist[ulistsize++] = *u;
}
endutxent();