mirror of https://github.com/AxioDL/tinyxml2.git
Add null-checks in `XMLTest()`
When either `expected` or `found` is `NULL`, `XMLTest()` will segfault on `strcmp()`. This patch adds null-checks, and passes the test if both `expected` and `found` are `NULL`.
This commit is contained in:
parent
a7edb883f0
commit
13b2d73427
|
@ -30,7 +30,12 @@ int gFail = 0;
|
||||||
|
|
||||||
bool XMLTest (const char* testString, const char* expected, const char* found, bool echo=true, bool extraNL=false )
|
bool XMLTest (const char* testString, const char* expected, const char* found, bool echo=true, bool extraNL=false )
|
||||||
{
|
{
|
||||||
bool pass = !strcmp( expected, found );
|
bool pass;
|
||||||
|
if ( !expected && !found )
|
||||||
|
pass = true;
|
||||||
|
else if ( !expected || !found )
|
||||||
|
pass = false;
|
||||||
|
else pass = !strcmp( expected, found );
|
||||||
if ( pass )
|
if ( pass )
|
||||||
printf ("[pass]");
|
printf ("[pass]");
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue