Skip to content

Commit 7e74074

Browse files
committed
[clang][Interp] Fix null Descriptor dereference in ArrayElemPtrPop
ByteCode interpretor could deref a null descriptor when handling typeid (or function pointers) in ArrayElemPtrPop. We need to treat this case as having no descriptor
1 parent 489a921 commit 7e74074

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clang/lib/AST/ByteCode/Interp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3126,7 +3126,8 @@ inline bool ArrayElemPtrPop(InterpState &S, CodePtr OpPC) {
31263126
}
31273127

31283128
if (Offset.isZero()) {
3129-
if (Ptr.getFieldDesc()->isArray() && Ptr.getIndex() == 0) {
3129+
if (const Descriptor *Desc = Ptr.getFieldDesc();
3130+
Desc && Desc->isArray() && Ptr.getIndex() == 0) {
31303131
S.Stk.push<Pointer>(Ptr.atIndex(0).narrow());
31313132
return true;
31323133
}

0 commit comments

Comments
 (0)