Merge "Avoid accidentally sharing preparers slice across factories" am: 7160699044

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1622438

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6942f827c8a636745a76e62987cb0ba4e1df5698
This commit is contained in:
Paul Duffin
2021-03-09 03:25:36 +00:00
committed by Automerger Merge Worker

View File

@@ -564,7 +564,11 @@ type fixtureFactory struct {
} }
func (f *fixtureFactory) Extend(preparers ...FixturePreparer) FixtureFactory { func (f *fixtureFactory) Extend(preparers ...FixturePreparer) FixtureFactory {
all := append(f.preparers, dedupAndFlattenPreparers(f.preparers, preparers)...) // Create a new slice to avoid accidentally sharing the preparers slice from this factory with
// the extending factories.
var all []*simpleFixturePreparer
all = append(all, f.preparers...)
all = append(all, dedupAndFlattenPreparers(f.preparers, preparers)...)
// Copy the existing factory. // Copy the existing factory.
extendedFactory := &fixtureFactory{} extendedFactory := &fixtureFactory{}
*extendedFactory = *f *extendedFactory = *f