Skip to content

Commit

Permalink
Check for correct element type before accessing namespace definitions.
Browse files Browse the repository at this point in the history
When recursively removing namespaces, make sure that we only access
node->nsdef for elements whose struct has that field.

This caused a crash in test_remove_entity_namespace on one machine
(but not the other).
  • Loading branch information
ender672 committed Nov 13, 2011
1 parent 7ef23cb commit 7ec7524
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ext/nokogiri/xml_document.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ static void recursively_remove_namespaces_from_node(xmlNodePtr node)
for (child = node->children ; child ; child = child->next)
recursively_remove_namespaces_from_node(child);

if (node->nsDef) {
if (((node->type == XML_ELEMENT_NODE) ||
(node->type == XML_XINCLUDE_START) ||
(node->type == XML_XINCLUDE_END)) &&
node->nsDef) {
xmlFreeNsList(node->nsDef);
node->nsDef = NULL;
}
Expand Down

0 comments on commit 7ec7524

Please sign in to comment.