From 5c17ac003abb5bc9b6fe41ae5b20bc2db9efcd68 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Sat, 20 Jun 2020 19:38:21 +0900 Subject: [PATCH] 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) --- android/override_module.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/android/override_module.go b/android/override_module.go index 90ddf5049..6b246db41 100644 --- a/android/override_module.go +++ b/android/override_module.go @@ -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) {