From b68ea3bb1d75e1f2cda1bfda26c7dc9fe4251184 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 25 Jul 2012 08:47:10 -0700 Subject: [PATCH] new patch from @lightmare for protecting against expression.to_string misusage - closes #1232 --- include/mapnik/expression_string.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/mapnik/expression_string.hpp b/include/mapnik/expression_string.hpp index aae6fa09e..dcf333815 100644 --- a/include/mapnik/expression_string.hpp +++ b/include/mapnik/expression_string.hpp @@ -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 -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 -std::string to_expression_string(boost::shared_ptr const& x) +std::string to_expression_string(boost::shared_ptr 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 } }