diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-07-26 21:04:52 -0700 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-07-26 21:04:52 -0700 |
commit | f738675f1d857917e54751961da28d7e5aaaf440 (patch) | |
tree | 698c8d955079c1efbb65881f5d526393a88cd0fc | |
parent | bd7a8fa4bfa361b06cdbb497021545f0f7ba66ac (diff) |
Fix two UB sanitizer false positives
Change the expression to reference the array element indirectly. The memory
block can be bigger than the structure so it's invalid to use static data[]
size for bounds checking.
-rw-r--r-- | src/pugixml.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index b3195f7..07f3a33 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -7305,7 +7305,7 @@ PUGI__NS_BEGIN if (_root_size + size <= _root->capacity) { - void* buf = _root->data + _root_size; + void* buf = &_root->data[0] + _root_size; _root_size += size; return buf; } @@ -7355,7 +7355,7 @@ PUGI__NS_BEGIN new_size = (new_size + xpath_memory_block_alignment - 1) & ~(xpath_memory_block_alignment - 1); // we can only reallocate the last object - assert(ptr == 0 || static_cast<char*>(ptr) + old_size == _root->data + _root_size); + assert(ptr == 0 || static_cast<char*>(ptr) + old_size == &_root->data[0] + _root_size); // adjust root size so that we have not allocated the object at all bool only_object = (_root_size == old_size); |