File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -412,6 +412,17 @@ func (d *partialArray) set(key string, val *lazyNode) error {
412412 if err != nil {
413413 return err
414414 }
415+
416+ if idx < 0 {
417+ if ! SupportNegativeIndices {
418+ return errors .Wrapf (ErrInvalidIndex , "Unable to access invalid index: %d" , idx )
419+ }
420+ if idx < - len (* d ) {
421+ return errors .Wrapf (ErrInvalidIndex , "Unable to access invalid index: %d" , idx )
422+ }
423+ idx += len (* d )
424+ }
425+
415426 (* d )[idx ] = val
416427 return nil
417428}
@@ -462,6 +473,16 @@ func (d *partialArray) get(key string) (*lazyNode, error) {
462473 return nil , err
463474 }
464475
476+ if idx < 0 {
477+ if ! SupportNegativeIndices {
478+ return nil , errors .Wrapf (ErrInvalidIndex , "Unable to access invalid index: %d" , idx )
479+ }
480+ if idx < - len (* d ) {
481+ return nil , errors .Wrapf (ErrInvalidIndex , "Unable to access invalid index: %d" , idx )
482+ }
483+ idx += len (* d )
484+ }
485+
465486 if idx >= len (* d ) {
466487 return nil , errors .Wrapf (ErrInvalidIndex , "Unable to access invalid index: %d" , idx )
467488 }
You can’t perform that action at this time.
0 commit comments