Skip to content

Commit

Permalink
return an error unmarshaling av.L into an array that is too small
Browse files Browse the repository at this point in the history
  • Loading branch information
guregu committed May 1, 2020
1 parent e3b61e5 commit b868cf6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ func unmarshalReflect(av *dynamodb.AttributeValue, rv reflect.Value) error {
rv.Set(arr)
return nil
case av.L != nil:
if len(av.L) > arr.Len() {
return fmt.Errorf("dynamo: cannot marshal %s into %s; too small (dst len: %d, src len: %d)", avTypeName(av), arr.Type().String(), arr.Len(), len(av.L))
}
for i, innerAV := range av.L {
innerRV := reflect.New(elemtype).Elem()
if err := unmarshalReflect(innerAV, innerRV); err != nil {
Expand Down

0 comments on commit b868cf6

Please sign in to comment.