]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #3830: Force initalization of thread local variables.
authorOleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) <oshumeik@cisco.com>
Fri, 28 Apr 2023 11:33:08 +0000 (11:33 +0000)
committerOleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) <oshumeik@cisco.com>
Fri, 28 Apr 2023 11:33:08 +0000 (11:33 +0000)
Merge in SNORT/snort3 from ~OSHUMEIK/snort3:fix_nullptr_memman to master

Squashed commit of the following:

commit 09db004f568e7d14f81aad4d30533e3f758e6b0c
Author: Oleksii Shumeiko <oshumeik@cisco.com>
Date:   Mon Apr 24 14:24:37 2023 +0300

    memory: provide a default value for pointers if the module has not been initialized

src/memory/heap_interface.cc

index ef88702ae780fea916e17aebe67708f6d36c012f..d4542bde3336437ec357651c03148f6e2d27de9c 100644 (file)
@@ -56,8 +56,10 @@ class JemallocInterface : public HeapInterface
 
 static size_t stats_mib[2], mib_len = 2;
 
-static THREAD_LOCAL uint64_t* alloc_ptr = nullptr;
-static THREAD_LOCAL uint64_t* dealloc_ptr = nullptr;
+static const uint64_t alloc_zero = 0;
+static const uint64_t dealloc_zero = 0;
+static THREAD_LOCAL const uint64_t* alloc_ptr = &alloc_zero;
+static THREAD_LOCAL const uint64_t* dealloc_ptr = &dealloc_zero;
 
 static ControlConn* s_ctrlconn = nullptr;
 static void log_jem_stats(void *,const char *buf)