Fix invalid memory error for python binary build

The root cause is we didn't check if the optionalpath is valid or not,
the registerbuildation function directly invoke the path var and
cause the invalid memory error. We just return if the launcher doesn't
exist.

The ctx.VisitDirectDepsWithTag() also handles allowmissingdependency so
we are ok if launcher doesn't exist.

Test: N/A
Bug: b/116698229, b/67510844
Change-Id: I40941079a64d7797ab879fc5edaa29e835b493a0
This commit is contained in:
Nan Zhang
2018-09-26 15:14:10 -07:00
parent f9641687f5
commit cba97e69ab
2 changed files with 6 additions and 6 deletions

View File

@@ -84,15 +84,15 @@ func (binary *binaryDecorator) bootstrap(ctx android.ModuleContext, actualVersio
main := binary.getPyMainFile(ctx, srcsPathMappings)
var launcherPath android.Path
var launcherPath android.OptionalPath
if embeddedLauncher {
ctx.VisitDirectDepsWithTag(launcherTag, func(m android.Module) {
if provider, ok := m.(IntermPathProvider); ok {
if launcherPath != nil {
if launcherPath.Valid() {
panic(fmt.Errorf("launcher path was found before: %q",
launcherPath))
}
launcherPath = provider.IntermPathForModuleOut().Path()
launcherPath = provider.IntermPathForModuleOut()
}
})
}