From 232256e136056ddac12d8b8d5a41cc20c27cc26f Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 5 Mar 2012 10:44:20 -0800 Subject: [PATCH] load_map_string: do not pass optional arg by const& and better error if string is empty --- include/mapnik/load_map.hpp | 2 +- src/load_map.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/mapnik/load_map.hpp b/include/mapnik/load_map.hpp index 3dbba801f..7858c9395 100644 --- a/include/mapnik/load_map.hpp +++ b/include/mapnik/load_map.hpp @@ -32,7 +32,7 @@ namespace mapnik { MAPNIK_DECL void load_map(Map & map, std::string const& filename, bool strict = false); -MAPNIK_DECL void load_map_string(Map & map, std::string const& str, bool strict = false, std::string const& base_path=""); +MAPNIK_DECL void load_map_string(Map & map, std::string const& str, bool strict = false, std::string base_path=""); } #endif // MAPNIK_LOAD_MAP_HPP diff --git a/src/load_map.cpp b/src/load_map.cpp index ddb076e80..8afdd97a4 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -184,8 +184,13 @@ void load_map(Map & map, std::string const& filename, bool strict) parser.parse_map(map, pt); } -void load_map_string(Map & map, std::string const& str, bool strict, std::string const& base_path) +void load_map_string(Map & map, std::string const& str, bool strict, std::string base_path) { + if (str.empty()) + { + throw config_error( "Cannot load map, XML string is empty" ) ; + } + ptree pt; #ifdef HAVE_LIBXML2 if (!base_path.empty())