From bae2132bd512a1bd4fff4cb3958f960ae66a534f Mon Sep 17 00:00:00 2001 From: Mark Mandriota Date: Tue, 16 Dec 2025 19:48:35 +0100 Subject: [PATCH] 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. --- src/dictziplib.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dictziplib.hpp b/src/dictziplib.hpp index 2e81873..d1d43ab 100644 --- a/src/dictziplib.hpp +++ b/src/dictziplib.hpp @@ -18,7 +18,10 @@ class DictData public: static const size_t DICT_CACHE_SIZE = 5; - DictData() {} + DictData() { + this->chunks = nullptr; + this->offsets = nullptr; + } ~DictData() { close(); } bool open(const std::string &filename, int computeCRC); void close();