Fix an use-after-free

Because we “delete all node” and then we use the content of one of these
nodes we got earlier.
This commit is contained in:
louiz’
2017-01-06 23:09:17 +01:00
parent 5b56007828
commit 17411e6b44
+2 -1
View File
@@ -54,10 +54,11 @@ void HelloStep2(XmppComponent&, AdhocSession& session, XmlNode& command_node)
{ {
if (const XmlNode* value = name_field->get_child("value", "jabber:x:data")) if (const XmlNode* value = name_field->get_child("value", "jabber:x:data"))
{ {
const std::string value_str = value->get_inner();
command_node.delete_all_children(); command_node.delete_all_children();
XmlSubNode note(command_node, "note"); XmlSubNode note(command_node, "note");
note["type"] = "info"; note["type"] = "info";
note.set_inner("Hello "s + value->get_inner() + "!"s); note.set_inner("Hello "s + value_str + "!"s);
return; return;
} }
} }