From 64cb7c964a8f33d473fba87af790e2c281dc1451 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Tue, 14 Sep 2021 17:32:49 -0700 Subject: [PATCH] Fix panic when a module has an invalid output path dep.OutputFile().Path() can panic if the OutputFile is invalid, so move more of the code into the check for validity. This changes the go crash into a build error. Bug: 158624492 Test: Apply the patchset 1 of ag/11815659, lunch aosp_x86_64-eng, m Change-Id: Ic8a728be1b570ac73be7b2b9461676f9fd99c266 --- java/app.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/java/app.go b/java/app.go index 5104f07d6..a62e442ac 100755 --- a/java/app.go +++ b/java/app.go @@ -760,18 +760,18 @@ func collectAppDeps(ctx android.ModuleContext, app appDepsInterface, } lib := dep.OutputFile() - path := lib.Path() - if seenModulePaths[path.String()] { - return false - } - seenModulePaths[path.String()] = true - - if checkNativeSdkVersion && dep.SdkVersion() == "" { - ctx.PropertyErrorf("jni_libs", "JNI dependency %q uses platform APIs, but this module does not", - otherName) - } - if lib.Valid() { + path := lib.Path() + if seenModulePaths[path.String()] { + return false + } + seenModulePaths[path.String()] = true + + if checkNativeSdkVersion && dep.SdkVersion() == "" { + ctx.PropertyErrorf("jni_libs", "JNI dependency %q uses platform APIs, but this module does not", + otherName) + } + jniLibs = append(jniLibs, jniLib{ name: ctx.OtherModuleName(module), path: path,