Skip to content

Commit dfa96d5

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

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-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()) {

clang/test/Analysis/Checkers/CHERI/subobject-representability-mips64.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,12 @@ struct R2 {
3434
char a[0x8000]; // expected-warning{{Field 'a' of type 'char[32768]' (size 32768) requires 64 byte alignment for precise bounds; field offset is 113 (aligned to 1); Current bounds: 64-32896}}
3535
char y[32]; // expected-note{{15/32}}
3636
};
37+
38+
// Previously triggered a crash.
39+
struct a {
40+
unsigned b;
41+
};
42+
void c(unsigned a::*d) {
43+
d == &a::b;
44+
c(&a::b);
45+
}

0 commit comments

Comments
 (0)