]> granicus.if.org Git - jq/commitdiff
Fix off-by-one bug in #1108 fix
authorNicolas Williams <nico@cryptonector.com>
Thu, 2 Mar 2017 04:45:02 +0000 (22:45 -0600)
committerNicolas Williams <nico@cryptonector.com>
Thu, 2 Mar 2017 04:45:02 +0000 (22:45 -0600)
src/jv.c
tests/jq.test

index c2448a7c401b19e27600c45ec7188a0a3b2c947a..979d188e853b5b0ba71b2deaaa3c91aeef635bac 100644 (file)
--- a/src/jv.c
+++ b/src/jv.c
@@ -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));
index 930bf79445604e489ad7dbc3d8b7d966766e78b0..963595b004f074b96bc097443654a762b76a9857 100644 (file)
@@ -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