Skip to content

Commit d32b5ca

Browse files
tbaederryuxuanchen1997
authored andcommitted
[clang][Interp][NFC] Protect getPtrBase{,Pop} ops from past-end ptrs
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250522
1 parent 626022b commit d32b5ca

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

clang/lib/AST/Interp/Interp.h

Lines changed: 8 additions & 2 deletions
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)