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

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ifcfdf52a239dd9a4a1591cf2a9980a0db87a11e3
This commit is contained in:
Paul Duffin
2021-03-09 04:08:44 +00:00
committed by Automerger Merge Worker

View File

@@ -564,7 +564,11 @@ type fixtureFactory struct {
}
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.
extendedFactory := &fixtureFactory{}
*extendedFactory = *f