don't modify argument slices

There were a couple spots where argument slices weren't being copied
before `append` was called, which could possibly modify the caller's
slice data.
This commit is contained in:
James Bardin 2018-12-10 11:55:55 -05:00
parent 55469cd416
commit b5de50c0a2
2 changed files with 6 additions and 0 deletions

View File

@ -174,6 +174,9 @@ func (r *DiffFieldReader) readPrimitive(
func (r *DiffFieldReader) readSet(
address []string, schema *Schema) (FieldReadResult, error) {
// copy address to ensure we don't modify the argument
address = append([]string(nil), address...)
prefix := strings.Join(address, ".") + "."
// Create the set that will be our result

View File

@ -98,6 +98,9 @@ func (r *MapFieldReader) readPrimitive(
func (r *MapFieldReader) readSet(
address []string, schema *Schema) (FieldReadResult, error) {
// copy address to ensure we don't modify the argument
address = append([]string(nil), address...)
// Get the number of elements in the list
countRaw, err := r.readPrimitive(
append(address, "#"), &Schema{Type: TypeInt})