diff options
author | 2014-04-22 20:40:37 +0000 | |
---|---|---|
committer | 2014-04-22 20:40:37 +0000 | |
commit | e7049ca991bab85793c3aade6f514f1cd3d1633c (patch) | |
tree | 1d91ddded0955d073d46da1f61baf6d12d754df4 | |
parent | null a pointer to prevent double free. from Dirk Engling (diff) | |
download | wireguard-openbsd-e7049ca991bab85793c3aade6f514f1cd3d1633c.tar.xz wireguard-openbsd-e7049ca991bab85793c3aade6f514f1cd3d1633c.zip |
malloc/memset->calloc. with bonus null check. from peter malone.
-rw-r--r-- | sbin/init/init.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sbin/init/init.c b/sbin/init/init.c index b87b2b2a4fd..916a029eced 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.49 2014/01/03 22:29:00 millert Exp $ */ +/* $OpenBSD: init.c,v 1.50 2014/04/22 20:40:37 tedu Exp $ */ /* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */ /*- @@ -860,8 +860,9 @@ new_session(session_t *sprev, int session_index, struct ttyent *typ) typ->ty_getty == 0) return (0); - sp = (session_t *) malloc(sizeof (session_t)); - memset(sp, 0, sizeof *sp); + sp = calloc(1, sizeof (session_t)); + if (sp == NULL) + err(1, "calloc"); sp->se_flags = SE_PRESENT; sp->se_index = session_index; |