[clang][bytecode] Fix a crash with typeid pointers (#154692)
That code is from a time when typeid pointers didn't exist. We can get there for non-block, non-integral pointers, but we can't meaningfully handle that case. Just return false. Fixes #153712
This commit is contained in:
parent
f306e0aeb2
commit
c9bb3bdbca
@ -1806,6 +1806,8 @@ inline bool GetPtrBase(InterpState &S, CodePtr OpPC, uint32_t Off) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!Ptr.isBlockPointer()) {
|
if (!Ptr.isBlockPointer()) {
|
||||||
|
if (!Ptr.isIntegralPointer())
|
||||||
|
return false;
|
||||||
S.Stk.push<Pointer>(Ptr.asIntPointer().baseCast(S.getASTContext(), Off));
|
S.Stk.push<Pointer>(Ptr.asIntPointer().baseCast(S.getASTContext(), Off));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1827,6 +1829,8 @@ inline bool GetPtrBasePop(InterpState &S, CodePtr OpPC, uint32_t Off,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!Ptr.isBlockPointer()) {
|
if (!Ptr.isBlockPointer()) {
|
||||||
|
if (!Ptr.isIntegralPointer())
|
||||||
|
return false;
|
||||||
S.Stk.push<Pointer>(Ptr.asIntPointer().baseCast(S.getASTContext(), Off));
|
S.Stk.push<Pointer>(Ptr.asIntPointer().baseCast(S.getASTContext(), Off));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,12 @@ struct __type_info_implementations {
|
|||||||
typedef __unique_impl __impl;
|
typedef __unique_impl __impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
class type_info {
|
class __pointer_type_info {
|
||||||
|
public:
|
||||||
|
int __flags = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class type_info : public __pointer_type_info {
|
||||||
protected:
|
protected:
|
||||||
typedef __type_info_implementations::__impl __impl;
|
typedef __type_info_implementations::__impl __impl;
|
||||||
__impl::__type_name_t __type_name;
|
__impl::__type_name_t __type_name;
|
||||||
@ -40,3 +45,10 @@ constexpr bool test() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
static_assert(test());
|
static_assert(test());
|
||||||
|
|
||||||
|
int dontcrash() {
|
||||||
|
auto& pti = static_cast<const std::__pointer_type_info&>(
|
||||||
|
typeid(int)
|
||||||
|
);
|
||||||
|
return pti.__flags == 0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user