diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-03-18 01:48:44 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-03-18 01:48:44 +0000 |
commit | ba2285d1bf4da2193978ec5ea7df8e44978e2ecc (patch) | |
tree | 27dbc6830458e91e1a79000d8092d5bc4b7724dc /lib/libevent | |
parent | 9d3be3c69372adc51ec3e98c19759463ab7948d7 (diff) |
Use recallocarray() to avoid leaving detritus in memory when resizing
the string buffer.
ok jsing millert
Diffstat (limited to 'lib/libevent')
-rw-r--r-- | lib/libevent/buffer.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libevent/buffer.c b/lib/libevent/buffer.c index 14f0cd9762b..79b6da3727b 100644 --- a/lib/libevent/buffer.c +++ b/lib/libevent/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.30 2016/09/03 11:31:17 nayden Exp $ */ +/* $OpenBSD: buffer.c,v 1.31 2017/03/18 01:48:43 deraadt Exp $ */ /* * Copyright (c) 2002, 2003 Niels Provos <provos@citi.umich.edu> @@ -359,7 +359,8 @@ evbuffer_expand(struct evbuffer *buf, size_t datlen) if (buf->orig_buffer != buf->buffer) evbuffer_align(buf); - if ((newbuf = realloc(buf->buffer, length)) == NULL) + if ((newbuf = recallocarray(buf->buffer, buf->totallen, + length, 1)) == NULL) return (-1); buf->orig_buffer = buf->buffer = newbuf; |