lib,asn1_utils: fix out of bounds access on zero-sized array

* fix error: ... offset 0 is out of the bounds [0, 0] [-Werror=array-bounds]
* fix note: destination object of size 0 allocated by ‘operator new []’
--> data_ = new T[cap_];
This commit is contained in:
Robert Falkenberg 2022-05-13 16:47:52 +02:00
parent 58f71b10b6
commit 0c9ba5b87e
1 changed files with 6 additions and 2 deletions

View File

@ -193,8 +193,12 @@ public:
{
size_ = nof_items;
cap_ = nof_items;
data_ = new T[cap_];
std::copy(ptr, ptr + size_, data_);
if (ptr != NULL) {
data_ = new T[cap_];
std::copy(ptr, ptr + size_, data_);
} else {
data_ = NULL;
}
}
~dyn_array()
{