summaryrefslogtreecommitdiffstats
path: root/buf.c
diff options
context:
space:
mode:
Diffstat (limited to 'buf.c')
-rw-r--r--buf.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/buf.c b/buf.c
index c9cb4332..c9dcef5d 100644
--- a/buf.c
+++ b/buf.c
@@ -216,8 +216,9 @@ static void buf_put_bytes(val buf, val pos, mem_t *ptr, cnum size, val self)
{
struct buf *b = buf_handle(buf, self);
cnum p = buf_check_index(pos, self);
- if (p >= c_num(b->len))
- buf_do_set_len(buf, b, plus(pos, num_fast(size)), nil, self);
+ val req_len = plus(pos, num_fast(size));
+ if (gt(req_len, b->len))
+ buf_do_set_len(buf, b, req_len, nil, self);
memcpy(b->data + p, ptr, size);
}