summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-04-11 12:07:03 +0000
committered <ed@FreeBSD.org>2010-04-11 12:07:03 +0000
commit22858658af4aa248638b9368d74ebd0b9779a046 (patch)
treea3074f7504503c32f5d2659a0a9f308f8a3b34ba /usr.sbin
parentdabdbe3adaca80897f154c0a79f2e571e20571d0 (diff)
downloadFreeBSD-src-22858658af4aa248638b9368d74ebd0b9779a046.zip
FreeBSD-src-22858658af4aa248638b9368d74ebd0b9779a046.tar.gz
Don't forget to catch realloc() errors.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/lastlogin/lastlogin.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/usr.sbin/lastlogin/lastlogin.c b/usr.sbin/lastlogin/lastlogin.c
index 9c3d433..4c08547 100644
--- a/usr.sbin/lastlogin/lastlogin.c
+++ b/usr.sbin/lastlogin/lastlogin.c
@@ -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();
OpenPOWER on IntegriCloud