new patch from @lightmare for protecting against expression.to_string misusage - closes #1232

This commit is contained in:
Dane Springmeyer 2012-07-25 08:47:10 -07:00
parent ad90db2eb0
commit b68ea3bb1d

View file

@ -36,7 +36,7 @@ MAPNIK_DECL std::string to_expression_string(expr_node const& node);
/*
The following two templates are intentionally invalid and will prompt
a compile error if ever instanciated. This should prevent accidentally
a compile error if ever instantiated. This should prevent accidentally
passing a pointer (either raw or shared) as the argument. Without them,
the compiler could construct a temporary expr_node(bool) using
implicit pointer-to-bool conversion, thus any non-null pointer
@ -44,19 +44,19 @@ would yield "true".
*/
template <typename T>
std::string to_expression_string(T const* x)
std::string to_expression_string(T const* expr_node_ptr)
{
x = 0;
throw std::logic_error("to_expression_string() called with pointer argument");
return std::string();
// compile error intended here; comment on the next line shows in clang output
return expr_node_ptr; // to_expression_string() called with pointer argument
}
template <typename T>
std::string to_expression_string(boost::shared_ptr<T> const& x)
std::string to_expression_string(boost::shared_ptr<T> const& expr_node_ptr)
{
x = 0;
throw std::logic_error("to_expression_string() called with pointer argument");
return std::string();
// compile error intended here; comment on the next line shows in clang output
return expr_node_ptr; // to_expression_string() called with pointer argument
}
}