mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
fix nullptr passed to memcmp/memcpy reported by ubsan
This commit is contained in:
parent
4508514666
commit
230812093b
@ -159,7 +159,7 @@ public:
|
||||
if (newCapacity > _capacity)
|
||||
{
|
||||
T* ptr = new T[newCapacity];
|
||||
if (preserveContent)
|
||||
if (preserveContent && _ptr)
|
||||
{
|
||||
std::memcpy(ptr, _ptr, _used * sizeof(T));
|
||||
}
|
||||
@ -266,10 +266,11 @@ public:
|
||||
{
|
||||
if (_used == other._used)
|
||||
{
|
||||
if (std::memcmp(_ptr, other._ptr, _used * sizeof(T)) == 0)
|
||||
if (_ptr && other._ptr && std::memcmp(_ptr, other._ptr, _used * sizeof(T)) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else return _used == 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user