Only call get_last_child() if the node has children
Explain that the behaviour is otherwise undefined, in the comment.
This commit is contained in:
@@ -380,7 +380,7 @@ void XmppComponent::handle_message(const Stanza& stanza)
|
|||||||
// We consider this to be true, unless the error condition is
|
// We consider this to be true, unless the error condition is
|
||||||
// specified and is not in the kickable_errors set
|
// specified and is not in the kickable_errors set
|
||||||
bool kickable_error = true;
|
bool kickable_error = true;
|
||||||
if (error)
|
if (error && error->has_children())
|
||||||
{
|
{
|
||||||
const XmlNode* condition = error->get_last_child();
|
const XmlNode* condition = error->get_last_child();
|
||||||
if (kickable_errors.find(condition->get_name()) == kickable_errors.end())
|
if (kickable_errors.find(condition->get_name()) == kickable_errors.end())
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ public:
|
|||||||
XmlNode* add_child(XmlNode* child);
|
XmlNode* add_child(XmlNode* child);
|
||||||
XmlNode* add_child(XmlNode&& child);
|
XmlNode* add_child(XmlNode&& child);
|
||||||
/**
|
/**
|
||||||
* Returns the last of the children
|
* Returns the last of the children. If the node doesn't have any child,
|
||||||
|
* the behaviour is undefined. The user should make sure this is the case
|
||||||
|
* by calling has_children() for example.
|
||||||
*/
|
*/
|
||||||
XmlNode* get_last_child() const;
|
XmlNode* get_last_child() const;
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user