From a44c9402c20493f0964a1296dd38d313216fbd4d Mon Sep 17 00:00:00 2001 From: bitflash-maintainer Date: Wed, 2 Sep 2026 06:51:07 +0000 Subject: util: initialise CCriticalSection's diagnostic fields at construction pszFile/nLine were first written by CRITICAL_BLOCK on entry, so an instance embedded in a dynamically allocated object (CNode::cs_vSend, cs_vRecv, cs_inventory) held indeterminate values until its first lock -- anything reading them for diagnostics dereferenced a wild pointer. --- src/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/util.h b/src/util.h index d72518b..58d1638 100644 --- a/src/util.h +++ b/src/util.h @@ -199,7 +199,7 @@ protected: public: char* pszFile; int nLine; - explicit CCriticalSection() { InitializeCriticalSection(&cs); } + explicit CCriticalSection() : pszFile(NULL), nLine(0) { InitializeCriticalSection(&cs); } ~CCriticalSection() { DeleteCriticalSection(&cs); } void Enter() { EnterCriticalSection(&cs); } void Leave() { LeaveCriticalSection(&cs); } -- cgit v1.2.3