Skip to content

Commit 0fedfd8

Browse files
committed
[clang][Interp][NFC] Protect getPtrBase{,Pop} ops from past-end ptrs
1 parent bf76290 commit 0fedfd8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

clang/lib/AST/Interp/Interp.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,10 @@ inline bool GetPtrBase(InterpState &S, CodePtr OpPC, uint32_t Off) {
15711571
return false;
15721572
if (!CheckSubobject(S, OpPC, Ptr, CSK_Base))
15731573
return false;
1574-
S.Stk.push<Pointer>(Ptr.atField(Off));
1574+
const Pointer &Result = Ptr.atField(Off);
1575+
if (Result.isPastEnd())
1576+
return false;
1577+
S.Stk.push<Pointer>(Result);
15751578
return true;
15761579
}
15771580

@@ -1581,7 +1584,10 @@ inline bool GetPtrBasePop(InterpState &S, CodePtr OpPC, uint32_t Off) {
15811584
return false;
15821585
if (!CheckSubobject(S, OpPC, Ptr, CSK_Base))
15831586
return false;
1584-
S.Stk.push<Pointer>(Ptr.atField(Off));
1587+
const Pointer &Result = Ptr.atField(Off);
1588+
if (Result.isPastEnd())
1589+
return false;
1590+
S.Stk.push<Pointer>(Result);
15851591
return true;
15861592
}
15871593

0 commit comments

Comments
 (0)