summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/buffer.c b/buffer.c
index 8ff8c2f48..aee293f8b 100644
--- a/buffer.c
+++ b/buffer.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: buffer.c,v 1.17 2003/09/16 03:03:47 deraadt Exp $"); 15RCSID("$OpenBSD: buffer.c,v 1.18 2003/09/16 21:02:39 markus Exp $");
16 16
17#include "xmalloc.h" 17#include "xmalloc.h"
18#include "buffer.h" 18#include "buffer.h"
@@ -23,8 +23,11 @@ RCSID("$OpenBSD: buffer.c,v 1.17 2003/09/16 03:03:47 deraadt Exp $");
23void 23void
24buffer_init(Buffer *buffer) 24buffer_init(Buffer *buffer)
25{ 25{
26 buffer->alloc = 4096; 26 const u_int len = 4096;
27 buffer->buf = xmalloc(buffer->alloc); 27
28 buffer->alloc = 0;
29 buffer->buf = xmalloc(len);
30 buffer->alloc = len;
28 buffer->offset = 0; 31 buffer->offset = 0;
29 buffer->end = 0; 32 buffer->end = 0;
30} 33}
@@ -34,8 +37,10 @@ buffer_init(Buffer *buffer)
34void 37void
35buffer_free(Buffer *buffer) 38buffer_free(Buffer *buffer)
36{ 39{
37 memset(buffer->buf, 0, buffer->alloc); 40 if (buffer->alloc > 0) {
38 xfree(buffer->buf); 41 memset(buffer->buf, 0, buffer->alloc);
42 xfree(buffer->buf);
43 }
39} 44}
40 45
41/* 46/*