Skip to content

Commit dc6b2e2

Browse files
authored
Merge pull request #24657 from dcci/alias-ubsan
[AliasAnalysis] Check for nullptr before dereferencing.
2 parents e8773b5 + 642f64f commit dc6b2e2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/SILOptimizer/Analysis/AliasAnalysis.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,10 @@ AliasResult AliasAnalysis::aliasInner(SILValue V1, SILValue V2,
580580
LLVM_DEBUG(llvm::dbgs() << "ALIAS ANALYSIS:\n V1: " << *V1
581581
<< " V2: " << *V2);
582582

583+
// If this is SILUndef, return may alias.
584+
if (!V1->getFunction())
585+
return AliasResult::MayAlias;
586+
583587
// Pass in both the TBAA types so we can perform typed access TBAA and the
584588
// actual types of V1, V2 so we can perform class based TBAA.
585589
if (!typesMayAlias(TBAAType1, TBAAType2, *V1->getFunction()))

0 commit comments

Comments
 (0)