Skip to content

Commit 6cb7714

Browse files
LuisPovedaCanoBlyron
authored andcommitted
Add null pointer checks in xml_node insertion methods
1 parent 2fed713 commit 6cb7714

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

LibCarla/source/third-party/pugixml/pugixml.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5826,7 +5826,7 @@ namespace pugi
58265826
PUGI__FN xml_node xml_node::insert_child_before(xml_node_type type_, const xml_node& node)
58275827
{
58285828
if (!impl::allow_insert_child(type(), type_)) return xml_node();
5829-
if (!node._root || node._root->parent != _root) return xml_node();
5829+
if (!_root || !node._root || node._root->parent != _root) return xml_node();
58305830

58315831
impl::xml_allocator& alloc = impl::get_allocator(_root);
58325832
if (!alloc.reserve()) return xml_node();
@@ -5844,7 +5844,7 @@ namespace pugi
58445844
PUGI__FN xml_node xml_node::insert_child_after(xml_node_type type_, const xml_node& node)
58455845
{
58465846
if (!impl::allow_insert_child(type(), type_)) return xml_node();
5847-
if (!node._root || node._root->parent != _root) return xml_node();
5847+
if (!_root || !node._root || node._root->parent != _root) return xml_node();
58485848

58495849
impl::xml_allocator& alloc = impl::get_allocator(_root);
58505850
if (!alloc.reserve()) return xml_node();
@@ -5933,7 +5933,7 @@ namespace pugi
59335933
{
59345934
xml_node_type type_ = proto.type();
59355935
if (!impl::allow_insert_child(type(), type_)) return xml_node();
5936-
if (!node._root || node._root->parent != _root) return xml_node();
5936+
if (!_root || !node._root || node._root->parent != _root) return xml_node();
59375937

59385938
impl::xml_allocator& alloc = impl::get_allocator(_root);
59395939
if (!alloc.reserve()) return xml_node();
@@ -5951,7 +5951,7 @@ namespace pugi
59515951
{
59525952
xml_node_type type_ = proto.type();
59535953
if (!impl::allow_insert_child(type(), type_)) return xml_node();
5954-
if (!node._root || node._root->parent != _root) return xml_node();
5954+
if (!_root || !node._root || node._root->parent != _root) return xml_node();
59555955

59565956
impl::xml_allocator& alloc = impl::get_allocator(_root);
59575957
if (!alloc.reserve()) return xml_node();
@@ -6000,7 +6000,7 @@ namespace pugi
60006000
PUGI__FN xml_node xml_node::insert_move_after(const xml_node& moved, const xml_node& node)
60016001
{
60026002
if (!impl::allow_move(*this, moved)) return xml_node();
6003-
if (!node._root || node._root->parent != _root) return xml_node();
6003+
if (!_root || !node._root || node._root->parent != _root) return xml_node();
60046004
if (moved._root == node._root) return xml_node();
60056005

60066006
impl::xml_allocator& alloc = impl::get_allocator(_root);
@@ -6018,7 +6018,7 @@ namespace pugi
60186018
PUGI__FN xml_node xml_node::insert_move_before(const xml_node& moved, const xml_node& node)
60196019
{
60206020
if (!impl::allow_move(*this, moved)) return xml_node();
6021-
if (!node._root || node._root->parent != _root) return xml_node();
6021+
if (!_root || !node._root || node._root->parent != _root) return xml_node();
60226022
if (moved._root == node._root) return xml_node();
60236023

60246024
impl::xml_allocator& alloc = impl::get_allocator(_root);

0 commit comments

Comments
 (0)