diff options
Diffstat (limited to 'crypto/openssh/buffer.c')
| -rw-r--r-- | crypto/openssh/buffer.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/crypto/openssh/buffer.c b/crypto/openssh/buffer.c index bad0a260c1a2..0c29bb8f0fdd 100644 --- a/crypto/openssh/buffer.c +++ b/crypto/openssh/buffer.c @@ -23,8 +23,11 @@ RCSID("$OpenBSD: buffer.c,v 1.13 2001/04/12 19:15:24 markus Exp $"); void buffer_init(Buffer *buffer) { - buffer->alloc = 4096; - buffer->buf = xmalloc(buffer->alloc); + const u_int len = 4096; + + buffer->alloc = 0; + buffer->buf = xmalloc(len); + buffer->alloc = len; buffer->offset = 0; buffer->end = 0; } @@ -34,8 +37,10 @@ buffer_init(Buffer *buffer) void buffer_free(Buffer *buffer) { - memset(buffer->buf, 0, buffer->alloc); - xfree(buffer->buf); + if (buffer->alloc > 0) { + memset(buffer->buf, 0, buffer->alloc); + xfree(buffer->buf); + } } /* |
