Skip to content

Commit

Permalink
new patch from @lightmare for protecting against expression.to_string…
Browse files Browse the repository at this point in the history
… misusage - closes #1232
  • Loading branch information
Dane Springmeyer committed Jul 25, 2012
1 parent ad90db2 commit b68ea3b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions include/mapnik/expression_string.hpp
Expand Up @@ -36,27 +36,27 @@ 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
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
}
}

Expand Down

0 comments on commit b68ea3b

Please sign in to comment.