Don't forget to catch realloc() errors.

This commit is contained in:
ed 2010-04-11 12:07:03 +00:00
parent dabdbe3ada
commit 22858658af

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();