Skip to content

Commit 7f1efbb

Browse files
committed
[bugfix] Fix an ArrayOutOfBoundException with array:get
Closes #2317
1 parent b228d7b commit 7f1efbb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/org/exist/xquery/functions/array/ArrayFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathExce
249249
return new IntegerValue(array.getSize());
250250
case GET:
251251
final IntegerValue index = (IntegerValue) args[1].itemAt(0);
252-
return array.get(index.getInt() - 1);
252+
return array.get(index);
253253
case APPEND:
254254
return array.append(args[1]);
255255
case HEAD:

test/src/xquery/arrays/arrays.xql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ function arr:function-item-invalid() {
134134
$a("x")
135135
};
136136

137+
declare
138+
%test:assertError("FOAY0001")
139+
function arr:get-item-out-of-bounds() {
140+
let $a := [13, 10, 14]
141+
return
142+
array:get($a, 22)
143+
};
144+
137145
declare
138146
%test:args(1)
139147
%test:assertEmpty

0 commit comments

Comments
 (0)