Skip to content

Commit

Permalink
Fix potential NPE in ModuleFileFunction
Browse files Browse the repository at this point in the history
`SkyframeLookupResult#get` can return `null` even if `env.valuesMissing()` is `false`.

Closes bazelbuild#22152.

PiperOrigin-RevId: 629099024
Change-Id: I54e675ce7bdf012d966308fb60d99e9b04e2d75f
  • Loading branch information
fmeum authored and Kila2 committed May 13, 2024
1 parent f955e81 commit c6cde1e
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -596,11 +596,14 @@ private GetModuleFileResult getModuleFile(
if (env.valuesMissing()) {
return null;
}
List<Registry> registryObjects =
registryKeys.stream()
.map(registryResult::get)
.map(Registry.class::cast)
.collect(toImmutableList());
List<Registry> registryObjects = new ArrayList<>(registryKeys.size());
for (RegistryKey registryKey : registryKeys) {
Registry registry = (Registry) registryResult.get(registryKey);
if (registry == null) {
return null;
}
registryObjects.add(registry);
}

// Now go through the list of registries and use the first one that contains the requested
// module.
Expand Down

0 comments on commit c6cde1e

Please sign in to comment.