diff options
author | 2017-03-16 13:15:06 +0000 | |
---|---|---|
committer | 2017-03-16 13:15:06 +0000 | |
commit | e21846dbfd5ef8d7f4278a6ea76ba27f90b68cdb (patch) | |
tree | af8fcb207f42c93b13a604b083ed07d4b053558e /lib/libcrypto/buffer/buffer.c | |
parent | There was a file descripotor leak in the syslogd(8) ttymsg() error (diff) | |
download | wireguard-openbsd-e21846dbfd5ef8d7f4278a6ea76ba27f90b68cdb.tar.xz wireguard-openbsd-e21846dbfd5ef8d7f4278a6ea76ba27f90b68cdb.zip |
Use calloc() instead of malloc() followed by manually zeroing fields.
ok beck@ inoguchi@
Diffstat (limited to 'lib/libcrypto/buffer/buffer.c')
-rw-r--r-- | lib/libcrypto/buffer/buffer.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/libcrypto/buffer/buffer.c b/lib/libcrypto/buffer/buffer.c index e32abb14f35..ddc8f39408e 100644 --- a/lib/libcrypto/buffer/buffer.c +++ b/lib/libcrypto/buffer/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.22 2017/01/29 17:49:22 beck Exp $ */ +/* $OpenBSD: buffer.c,v 1.23 2017/03/16 13:15:06 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -73,14 +73,11 @@ BUF_MEM_new(void) { BUF_MEM *ret; - ret = malloc(sizeof(BUF_MEM)); - if (ret == NULL) { + if ((ret = calloc(1, sizeof(BUF_MEM))) == NULL) { BUFerror(ERR_R_MALLOC_FAILURE); return (NULL); } - ret->length = 0; - ret->max = 0; - ret->data = NULL; + return (ret); } |