From 27971703deecfb77ba9f7e757c298f6e366927d3 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Fri, 6 Jan 2017 20:13:22 -0800 Subject: [PATCH] Fix fencepost errors in start indexes. --- src/microcode/bytevector.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/microcode/bytevector.c b/src/microcode/bytevector.c index f99128a34..8b1eb5122 100644 --- a/src/microcode/bytevector.c +++ b/src/microcode/bytevector.c @@ -128,7 +128,7 @@ DEFINE_PRIMITIVE ("bytevector-fill!", Prim_bytevector_fill, 4, 4, 0) unsigned long length; uint8_t * v = (arg_bytevector (1, (&length))); unsigned long end = (arg_ulong_index_integer (3, (length + 1))); - unsigned long start = (arg_ulong_index_integer (2, end)); + unsigned long start = (arg_ulong_index_integer (2, (end + 1))); uint8_t value = (arg_byte (4)); memset ((v + start), value, (end - start)); } @@ -142,7 +142,7 @@ DEFINE_PRIMITIVE ("bytevector-copy", Prim_bytevector_copy, 3, 3, 0) unsigned long length; uint8_t * v = (arg_bytevector (1, (&length))); unsigned long end = (arg_ulong_index_integer (3, (length + 1))); - unsigned long start = (arg_ulong_index_integer (2, end)); + unsigned long start = (arg_ulong_index_integer (2, (end + 1))); PRIMITIVE_RETURN (memory_to_bytevector ((end - start), (v + start))); } } @@ -157,7 +157,7 @@ DEFINE_PRIMITIVE ("bytevector-copy!", Prim_bytevector_copyx, 5, 5, 0) unsigned long from_length; uint8_t * from_v = (arg_bytevector (3, (&from_length))); unsigned long from_end = (arg_ulong_index_integer (5, (from_length + 1))); - unsigned long from_start = (arg_ulong_index_integer (4, from_end)); + unsigned long from_start = (arg_ulong_index_integer (4, (from_end + 1))); unsigned long length = (from_end - from_start); if ((to_length - to_start) < length) error_bad_range_arg (5); -- 2.25.1