Reset contexts before calling LoadHook

If more than one loadhooks exist, calls to CreateModule will make an
error because the contexts object isn't reset and the same modules are
added more than once. This fixes the bug by initializing contexts object
every time.

Bug: 213297238
Test: manual
Change-Id: I545c1592c3217b764968a8937c962e9d58a85291
This commit is contained in:
Inseob Kim 2022-01-05 19:56:08 +09:00
parent a08e722192
commit 1e01a4e7c2

View file

@ -1368,16 +1368,16 @@ func runAndRemoveLoadHooks(ctx *Context, config interface{}, module *moduleInfo,
if v, exists := pendingHooks.Load(module.logicModule); exists {
hooks := v.(*[]LoadHook)
mctx := &loadHookContext{
baseModuleContext: baseModuleContext{
context: ctx,
config: config,
module: module,
},
scopedModuleFactories: scopedModuleFactories,
}
for _, hook := range *hooks {
mctx := &loadHookContext{
baseModuleContext: baseModuleContext{
context: ctx,
config: config,
module: module,
},
scopedModuleFactories: scopedModuleFactories,
}
hook(mctx)
newModules = append(newModules, mctx.newModules...)
deps = append(deps, mctx.ninjaFileDeps...)