Merge pull request #19587 from hashicorp/jbardin/safe-appends
don't modify argument slices
This commit is contained in:
commit
8ab5698e2a
|
@ -174,6 +174,9 @@ func (r *DiffFieldReader) readPrimitive(
|
||||||
|
|
||||||
func (r *DiffFieldReader) readSet(
|
func (r *DiffFieldReader) readSet(
|
||||||
address []string, schema *Schema) (FieldReadResult, error) {
|
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, ".") + "."
|
prefix := strings.Join(address, ".") + "."
|
||||||
|
|
||||||
// Create the set that will be our result
|
// Create the set that will be our result
|
||||||
|
|
|
@ -98,6 +98,9 @@ func (r *MapFieldReader) readPrimitive(
|
||||||
|
|
||||||
func (r *MapFieldReader) readSet(
|
func (r *MapFieldReader) readSet(
|
||||||
address []string, schema *Schema) (FieldReadResult, error) {
|
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
|
// Get the number of elements in the list
|
||||||
countRaw, err := r.readPrimitive(
|
countRaw, err := r.readPrimitive(
|
||||||
append(address, "#"), &Schema{Type: TypeInt})
|
append(address, "#"), &Schema{Type: TypeInt})
|
||||||
|
|
Loading…
Reference in New Issue