From 9a7f2d51807c182c7cb7e554c3be109ccd066ad8 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 4 May 2021 06:44:28 -0700 Subject: buf: bugfix: int-buf, uint-buf refer to alloc size. * buf.c (int_buf, uint_buf): Refer to the buffer length b->len rather than the underlying allocation size b->size. Referring to b->size will not only produce the wrong value when it is larger than len, but b->size can be null for a borrowed buffer, producing a crash. * tests/012/buf.tl: Tests. --- tests/012/buf.tl | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/012/buf.tl (limited to 'tests/012/buf.tl') diff --git a/tests/012/buf.tl b/tests/012/buf.tl new file mode 100644 index 00000000..1c8040d6 --- /dev/null +++ b/tests/012/buf.tl @@ -0,0 +1,4 @@ +(load "../common") + +(vtest (uint-buf (make-buf 8 255 16)) (pred (expt 2 64))) +(test (int-buf (make-buf 8 255 16)) -1) -- cgit v1.2.3