Skip to content

Commit bb3d261

Browse files
committed
[clang][Interp] Protect GetPtrField ops from unknown size arrays
1 parent 375761b commit bb3d261

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/lib/AST/Interp/Interp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,8 @@ inline bool GetPtrField(InterpState &S, CodePtr OpPC, uint32_t Off) {
12451245
return false;
12461246
if (!CheckRange(S, OpPC, Ptr, CSK_Field))
12471247
return false;
1248+
if (!CheckArray(S, OpPC, Ptr))
1249+
return false;
12481250
if (!CheckSubobject(S, OpPC, Ptr, CSK_Field))
12491251
return false;
12501252

clang/test/AST/Interp/arrays.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,3 +595,12 @@ int test_multiarray22() {
595595
}
596596

597597
#endif
598+
599+
namespace ArrayMemberAccess {
600+
struct A {
601+
int x;
602+
};
603+
void f(const A (&a)[]) {
604+
bool cond = a->x;
605+
}
606+
}

0 commit comments

Comments
 (0)