Skip to content

Commit

Permalink
Fix off-by-one bug in #1108 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicowilliams committed Mar 2, 2017
1 parent 65cbaac commit 9df19f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/jv.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ static jv jvp_array_slice(jv a, int start, int end) {
return jv_array();
}

if (a.offset + start > 1 << (sizeof(a.offset) * CHAR_BIT)) {
if (a.offset + start >= 1 << (sizeof(a.offset) * CHAR_BIT)) {
jv r = jv_array_sized(end - start);
for (int i = start; i < end; i++)
r = jv_array_append(r, jv_array_get(jv_copy(a), i));
Expand Down
4 changes: 2 additions & 2 deletions tests/jq.test
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ del(.[2:4],.[0],.[-2:])
# significantly slower under valgrind than .[<large number>] = value.
#
# We range down rather than up so that we have just one realloc.
reduce range(70010;69999;-1) as $i ([]; .[$i] = $i)|.[69999:70003]
reduce range(65540;65536;-1) as $i ([]; .[$i] = $i)|.[65536:]
null
[null,70000,70001,70002]
[null,65537,65538,65539,65540]

#
# Variables
Expand Down

0 comments on commit 9df19f5

Please sign in to comment.