Merge pull request #313 from valeriyvan/nulldereference

Fixing possible null pointer dereference
This commit is contained in:
Arseny Kapoulkine 2019-12-03 21:17:28 -08:00 committed by GitHub
commit 2e8631d2eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6264,15 +6264,17 @@ namespace pugi
return found.parent().first_element_by_path(next_segment, delimiter); return found.parent().first_element_by_path(next_segment, delimiter);
else else
{ {
for (xml_node_struct* j = found._root->first_child; j; j = j->next_sibling) if (found._root) {
{ for (xml_node_struct* j = found._root->first_child; j; j = j->next_sibling)
if (j->name && impl::strequalrange(j->name, path_segment, static_cast<size_t>(path_segment_end - path_segment))) {
{ if (j->name && impl::strequalrange(j->name, path_segment, static_cast<size_t>(path_segment_end - path_segment)))
xml_node subsearch = xml_node(j).first_element_by_path(next_segment, delimiter); {
xml_node subsearch = xml_node(j).first_element_by_path(next_segment, delimiter);
if (subsearch) return subsearch; if (subsearch) return subsearch;
} }
} }
}
return xml_node(); return xml_node();
} }