mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-14 02:57:45 +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)
|
if (newCapacity > _capacity)
|
||||||
{
|
{
|
||||||
T* ptr = new T[newCapacity];
|
T* ptr = new T[newCapacity];
|
||||||
if (preserveContent)
|
if (preserveContent && _ptr)
|
||||||
{
|
{
|
||||||
std::memcpy(ptr, _ptr, _used * sizeof(T));
|
std::memcpy(ptr, _ptr, _used * sizeof(T));
|
||||||
}
|
}
|
||||||
@ -266,10 +266,11 @@ public:
|
|||||||
{
|
{
|
||||||
if (_used == other._used)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
else return _used == 0;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user