Skip to content

Commit e1e788f

Browse files
authored
[clang][bytecode] Protect ia32_{lzcnt,tzcnt} against non-integers (#110699)
These are also called for vectors.
1 parent e379094 commit e1e788f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,10 @@ static bool interp__builtin_ia32_lzcnt(InterpState &S, CodePtr OpPC,
12051205
const InterpFrame *Frame,
12061206
const Function *Func,
12071207
const CallExpr *Call) {
1208+
QualType CallType = Call->getType();
1209+
if (!CallType->isIntegerType())
1210+
return false;
1211+
12081212
APSInt Val = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(0)));
12091213
pushInteger(S, Val.countLeadingZeros(), Call->getType());
12101214
return true;
@@ -1214,6 +1218,10 @@ static bool interp__builtin_ia32_tzcnt(InterpState &S, CodePtr OpPC,
12141218
const InterpFrame *Frame,
12151219
const Function *Func,
12161220
const CallExpr *Call) {
1221+
QualType CallType = Call->getType();
1222+
if (!CallType->isIntegerType())
1223+
return false;
1224+
12171225
APSInt Val = peekToAPSInt(S.Stk, *S.Ctx.classify(Call->getArg(0)));
12181226
pushInteger(S, Val.countTrailingZeros(), Call->getType());
12191227
return true;

0 commit comments

Comments
 (0)