Skip to content

Commit bc486d6

Browse files
committed
[CHERI CSA] Fix a crash in the sub-object representability checker.
1 parent d586b67 commit bc486d6

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/StaticAnalyzer/Checkers/PointerAlignmentChecker.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ int getTrailingZerosCount(const SVal &V, ProgramStateRef State,
268268

269269
// Sealed capabilities cannot be dereferenced, and any type-punning
270270
// will be dynamically checked during unsealing.
271-
if (V.getType(ASTCtx)->isCHERISealedCapabilityType(ASTCtx))
271+
auto Ty = V.getType(ASTCtx);
272+
if (!Ty.isNull() && Ty->isCHERISealedCapabilityType(ASTCtx))
272273
return -1;
273274

274275
if (V.isConstant()) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %cheri_purecap_cc1 -analyze %s \
2+
// RUN: -analyzer-checker=core,cheri.SubObjectRepresentability
3+
4+
struct a {
5+
unsigned b;
6+
};
7+
void c(unsigned a::*d) {
8+
d == &a::b;
9+
c(&a::b);
10+
}

0 commit comments

Comments
 (0)