Fix CID 1164579 (Explicit null dereferenced)

The report from Coverity Scan is a false positive.

Nevertheless the code can be rewritten and optimized
a little bit to fix that report.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2018-10-02 11:48:28 +02:00
parent 9a1f14f2aa
commit 04703ca8df

View File

@ -661,11 +661,16 @@ class GenericVectorEqEq : public GenericVector<T> {
template <typename T>
void GenericVector<T>::init(int size) {
size_used_ = 0;
size_reserved_ = 0;
data_ = nullptr;
if (size <= 0) {
data_ = nullptr;
size_reserved_ = 0;
} else {
if (size < kDefaultVectorSize) size = kDefaultVectorSize;
data_ = new T[size];
size_reserved_ = size;
}
clear_cb_ = nullptr;
compare_cb_ = nullptr;
reserve(size);
}
template <typename T>