diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2017-01-29 20:00:44 -0800 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2017-01-29 20:00:44 -0800 |
commit | f11c4d684703a240e9ba0b9b347052f141d00753 (patch) | |
tree | 3c5732c9d6106284404ce00e50fb55a56add51a0 /src | |
parent | d3b9e4e1e85d0aca562d0e6b62533e68e5a4a749 (diff) |
XPath: alloc_string no longer returns NULL
NULL return value will be reserved for the OOM error indicator.
Diffstat (limited to 'src')
-rw-r--r-- | src/pugixml.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 0813ae6..8e9e42b 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -10953,20 +10953,19 @@ PUGI__NS_BEGIN const char_t* alloc_string(const xpath_lexer_string& value) { - if (value.begin) - { - size_t length = static_cast<size_t>(value.end - value.begin); + if (!value.begin) + return PUGIXML_TEXT(""); - char_t* c = static_cast<char_t*>(_alloc->allocate_nothrow((length + 1) * sizeof(char_t))); - if (!c) throw_error_oom(); - assert(c); // workaround for clang static analysis + size_t length = static_cast<size_t>(value.end - value.begin); - memcpy(c, value.begin, length * sizeof(char_t)); - c[length] = 0; + char_t* c = static_cast<char_t*>(_alloc->allocate_nothrow((length + 1) * sizeof(char_t))); + if (!c) throw_error_oom(); + assert(c); // workaround for clang static analysis - return c; - } - else return 0; + memcpy(c, value.begin, length * sizeof(char_t)); + c[length] = 0; + + return c; } xpath_ast_node* parse_function_helper(ast_type_t type0, ast_type_t type1, size_t argc, xpath_ast_node* args[2]) |