diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2019-12-03 21:17:28 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-03 21:17:28 -0800 |
commit | 2e8631d2eb6f19c45b5405982c7ed0102326cfb2 (patch) | |
tree | 5b17c9c52fed56943a2457ccbdd64aa557c5ef3c | |
parent | 51d177e938843cfd422a5cd13e782e85106daf12 (diff) | |
parent | cda8623468750c1a6ac403290a838c589cd759b3 (diff) | |
download | pugixml-2e8631d2eb6f19c45b5405982c7ed0102326cfb2.zip pugixml-2e8631d2eb6f19c45b5405982c7ed0102326cfb2.tar.gz pugixml-2e8631d2eb6f19c45b5405982c7ed0102326cfb2.tar.bz2 |
Merge pull request #313 from valeriyvan/nulldereference
Fixing possible null pointer dereference
-rw-r--r-- | src/pugixml.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 1f08b10..80fe605 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -6264,15 +6264,17 @@ namespace pugi return found.parent().first_element_by_path(next_segment, delimiter); else { - 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))) - { - xml_node subsearch = xml_node(j).first_element_by_path(next_segment, delimiter); - - if (subsearch) return subsearch; - } - } + 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))) + { + xml_node subsearch = xml_node(j).first_element_by_path(next_segment, delimiter); + + if (subsearch) return subsearch; + } + } + } return xml_node(); } |