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)
diff --git a/android/override_module.go b/android/override_module.go
index 90ddf50..6b246db 100644
--- a/android/override_module.go
+++ b/android/override_module.go
@@ -223,6 +223,11 @@
// 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) {