mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 03:20:11 +01:00
fixed a bug in RefAnyCast causing a crash if the cast is invalid
This commit is contained in:
@@ -561,14 +561,18 @@ 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));
|
||||||
std::string s = "RefAnyCast: Failed to convert between Any types ";
|
if (!result)
|
||||||
if (operand._pHolder)
|
|
||||||
{
|
{
|
||||||
s.append(1, '(');
|
std::string s = "RefAnyCast: Failed to convert between Any types ";
|
||||||
s.append(operand._pHolder->type().name());
|
if (operand._pHolder)
|
||||||
s.append(" => ");
|
{
|
||||||
s.append(typeid(ValueType).name());
|
s.append(1, '(');
|
||||||
s.append(1, ')');
|
s.append(operand._pHolder->type().name());
|
||||||
|
s.append(" => ");
|
||||||
|
s.append(typeid(ValueType).name());
|
||||||
|
s.append(1, ')');
|
||||||
|
}
|
||||||
|
throw BadCastException(s);
|
||||||
}
|
}
|
||||||
return *result;
|
return *result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user