mirror of
https://github.com/Dushistov/sdcv.git
synced 2025-12-17 18:21:55 +00:00
fix: segmentation fault, non initialized pointers in dictziplib.hpp
In method void DictData::close() both if (this->chunks) and if (this->offsets) checks can pass even if no allocated memory is assigned to pointers, because both pointers were not initialized to anything, it is UB, so free were called on uninitialized values. Initializing both values to nullptr guarantees that both checks will fail if pointers were not modified, and free is not called.
This commit is contained in:
committed by
Evgeniy Dushistov
parent
5478f290a1
commit
bae2132bd5
@@ -18,7 +18,10 @@ class DictData
|
|||||||
public:
|
public:
|
||||||
static const size_t DICT_CACHE_SIZE = 5;
|
static const size_t DICT_CACHE_SIZE = 5;
|
||||||
|
|
||||||
DictData() {}
|
DictData() {
|
||||||
|
this->chunks = nullptr;
|
||||||
|
this->offsets = nullptr;
|
||||||
|
}
|
||||||
~DictData() { close(); }
|
~DictData() { close(); }
|
||||||
bool open(const std::string &filename, int computeCRC);
|
bool open(const std::string &filename, int computeCRC);
|
||||||
void close();
|
void close();
|
||||||
|
|||||||
Reference in New Issue
Block a user