Bug 1071: Add NULL check in get_dom_node_list_index
commitb7f45ca80b42a295cc654d8b50ff6d99517bd054
authorKalle Olavi Niemitalo <kon@iki.fi>
Sat, 4 Apr 2009 19:41:43 +0000 (4 22:41 +0300)
committerKalle Olavi Niemitalo <Kalle@Astalo.kon.iki.fi>
Sat, 4 Apr 2009 19:41:43 +0000 (4 22:41 +0300)
tree46cea939a59149fd9e0e05f9d53f04e08129384f
parent0c1a27ee9988a9fa5b66e0f1a1e3d682942f67a4
Bug 1071: Add NULL check in get_dom_node_list_index

If the parent parameter of get_dom_node_list_index referred to a node
that did not have children, then get_dom_node_list called by it could
return the address of a null pointer, and get_dom_node_list_index would
then pass that null pointer to get_dom_node_list_pos, which would crash.
That would be the same kind of crash as the one in get_dom_node_child.
It never happened in practice though: because all calls are in the form
get_dom_node_list_index(node->parent, node), the list must contain at
least the given node, and the pointer cannot be null.  The documentation
of get_dom_node_list_index allows arbitrary nodes as arguments however,
so it's best to add a check.
src/dom/node.c