From 914eae0db6f5ca7f5e5df508706e8c483abbd4eb Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Wed, 21 Nov 2018 22:40:24 -0500 Subject: Fix freeing empty buffer block --- bin/edi/buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bin/edi') diff --git a/bin/edi/buffer.c b/bin/edi/buffer.c index 86575ad3..927e4e39 100644 --- a/bin/edi/buffer.c +++ b/bin/edi/buffer.c @@ -75,8 +75,9 @@ void bufferDelete(struct Buffer *buf) { wchar_t *bufferDest(struct Buffer *buf, size_t len) { if (buf->len + len > buf->cap) { if (!buf->len) { + struct Block *empty = buf->block; buf->block = buf->block->prev; - free(buf->block); + free(empty); } while (len > buf->cap) buf->cap *= 2; buf->block = blockAlloc(buf->block, buf->cap); -- cgit 1.4.1