From: Oleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) Date: Fri, 28 Apr 2023 11:33:08 +0000 (+0000) Subject: Pull request #3830: Force initalization of thread local variables. X-Git-Tag: 3.1.61.0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a8daad612c51c3f7116d77a956319f435285324;p=thirdparty%2Fsnort3.git Pull request #3830: Force initalization of thread local variables. Merge in SNORT/snort3 from ~OSHUMEIK/snort3:fix_nullptr_memman to master Squashed commit of the following: commit 09db004f568e7d14f81aad4d30533e3f758e6b0c Author: Oleksii Shumeiko Date: Mon Apr 24 14:24:37 2023 +0300 memory: provide a default value for pointers if the module has not been initialized --- diff --git a/src/memory/heap_interface.cc b/src/memory/heap_interface.cc index ef88702ae..d4542bde3 100644 --- a/src/memory/heap_interface.cc +++ b/src/memory/heap_interface.cc @@ -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)