Check base property before using it

OverrideModule's `base` property should point a valid
module(OverridableModule).

It should be checked before using it.

Bug: 159503211
Test: add `override_apex` without `base`
      m emits error, not panic.
Change-Id: I1d7c9395cc9a7461e317dd4b6ddbec3a9e68e9bf
(cherry picked from commit 3851b0c1fe8e8ffd3d30b4b8a5289f39a2c98270)
This commit is contained in:
Jooyung Han
2020-06-20 19:38:21 +09:00
parent 1bb4665c40
commit 5c17ac003a

View File

@@ -223,6 +223,11 @@ var overrideBaseDepTag overrideBaseDependencyTag
// next phase.
func overrideModuleDepsMutator(ctx BottomUpMutatorContext) {
if module, ok := ctx.Module().(OverrideModule); ok {
base := String(module.getOverrideModuleProperties().Base)
if !ctx.OtherModuleExists(base) {
ctx.PropertyErrorf("base", "%q is not a valid module name", base)
return
}
// See if there's a prebuilt module that overrides this override module with prefer flag,
// in which case we call SkipInstall on the corresponding variant later.
ctx.VisitDirectDepsWithTag(PrebuiltDepTag, func(dep Module) {