diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java index 0117d2116..8c8e23a27 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java @@ -5094,6 +5094,9 @@ public class FHIRPathEngine { int i2 = -1; if (exp.parameterCount() == 2) { List n2 = execute(context, focus, exp.getParameters().get(1), true); + if (n2.isEmpty()|| !n2.get(0).isPrimitive() || !Utilities.isInteger(n2.get(0).primitiveValue())) { + return new ArrayList(); + } i2 = Integer.parseInt(n2.get(0).primitiveValue()); } @@ -5104,6 +5107,9 @@ public class FHIRPathEngine { return new ArrayList(); } if (exp.parameterCount() == 2) { + if (i1+i2 >= sw.length()) { + return new ArrayList(); + } s = sw.substring(i1, Math.min(sw.length(), i1+i2)); } else { s = sw.substring(i1);