Merged by openshift-bot
OpenShift Bot authored on 2015/11/14 07:16:25... | ... |
@@ -234,6 +234,16 @@ func (j *JSONPath) evalArray(input []reflect.Value, node *ArrayNode) ([]reflect. |
234 | 234 |
params[1].Value += value.Len() |
235 | 235 |
} |
236 | 236 |
|
237 |
+ sliceLength := value.Len() |
|
238 |
+ if params[1].Value != params[0].Value { // if you're requesting zero elements, allow it through. |
|
239 |
+ if params[0].Value >= sliceLength { |
|
240 |
+ return input, fmt.Errorf("array index out of bounds: index %d, length %d", params[0].Value, sliceLength) |
|
241 |
+ } |
|
242 |
+ if params[1].Value > sliceLength { |
|
243 |
+ return input, fmt.Errorf("array index out of bounds: index %d, length %d", params[1].Value-1, sliceLength) |
|
244 |
+ } |
|
245 |
+ } |
|
246 |
+ |
|
237 | 247 |
if !params[2].Known { |
238 | 248 |
value = value.Slice(params[0].Value, params[1].Value) |
239 | 249 |
} else { |