mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 11:06:50 +01:00
fixed a bug in RefAnyCast causing a crash if the cast is invalid
This commit is contained in:
@@ -561,6 +561,8 @@ const ValueType& RefAnyCast(const Any & operand)
|
|||||||
/// const MyType& tmp = RefAnyCast<MyType>(anAny);
|
/// const MyType& tmp = RefAnyCast<MyType>(anAny);
|
||||||
{
|
{
|
||||||
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
|
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
std::string s = "RefAnyCast: Failed to convert between Any types ";
|
std::string s = "RefAnyCast: Failed to convert between Any types ";
|
||||||
if (operand._pHolder)
|
if (operand._pHolder)
|
||||||
{
|
{
|
||||||
@@ -570,6 +572,8 @@ const ValueType& RefAnyCast(const Any & operand)
|
|||||||
s.append(typeid(ValueType).name());
|
s.append(typeid(ValueType).name());
|
||||||
s.append(1, ')');
|
s.append(1, ')');
|
||||||
}
|
}
|
||||||
|
throw BadCastException(s);
|
||||||
|
}
|
||||||
return *result;
|
return *result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user