Skip to content

Commit 657c33a

Browse files
committed
XPath: Silence static analysis false positive
klockworks reports that var->name() may be NULL; it can never be NULL for a valid variable, but this check costs us nothing to add so we might as well add it.
1 parent 3cdb7f4 commit 657c33a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/pugixml.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13100,8 +13100,11 @@ namespace pugi
1310013100

1310113101
// look for existing variable
1310213102
for (xpath_variable* var = _data[hash]; var; var = var->_next)
13103-
if (impl::strequal(var->name(), name))
13103+
{
13104+
const char_t* vn = var->name();
13105+
if (vn && impl::strequal(vn, name))
1310413106
return var;
13107+
}
1310513108

1310613109
return NULL;
1310713110
}
@@ -13152,8 +13155,11 @@ namespace pugi
1315213155

1315313156
// look for existing variable
1315413157
for (xpath_variable* var = _data[hash]; var; var = var->_next)
13155-
if (impl::strequal(var->name(), name))
13158+
{
13159+
const char_t* vn = var->name();
13160+
if (vn && impl::strequal(vn, name))
1315613161
return var->type() == type ? var : NULL;
13162+
}
1315713163

1315813164
// add new variable
1315913165
xpath_variable* result = impl::new_xpath_variable(type, name);

0 commit comments

Comments
 (0)