]> git.sesse.net Git - xml-template/blobdiff - c++0x/xml-template.cpp
Fix a Valgrind hit; we cannot take c_str() of a temporary object.
[xml-template] / c++0x / xml-template.cpp
index 5bbcb9b5dbeec7079a1b436118fc3f7a858eaaeb..317a561779fab53a7177d8376e1bbd37de585909 100644 (file)
@@ -196,13 +196,13 @@ void Substitute::process(xmlNode *node, bool clean)
                                // Attribute substitution.
                                if (begins_with(it.first, tag + "/")) {
                                        const xmlChar *attr_key = reinterpret_cast<const xmlChar *>(
-                                               it.first.substr(tag.size() + 1).c_str());
+                                               it.first.c_str() + tag.size() + 1);
                                        const xmlChar *attr_value = reinterpret_cast<const xmlChar *>(
                                                it.second->get_contents().c_str());
                                        xmlSetProp(child, attr_key, attr_value);
                                } else if ((!id.empty() && begins_with(it.first, "#" + id + "/"))) {
                                        const xmlChar *attr_key = reinterpret_cast<const xmlChar *>(
-                                               it.first.substr(tag.size() + 2).c_str());
+                                               it.first.c_str() + tag.size() + 2);
                                        const xmlChar *attr_value = reinterpret_cast<const xmlChar *>(
                                                it.second->get_contents().c_str());
                                        xmlSetProp(child, attr_key, attr_value);