diff options
| author | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-02 06:51:07 +0000 |
|---|---|---|
| committer | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-02 06:51:07 +0000 |
| commit | a44c9402c20493f0964a1296dd38d313216fbd4d (patch) | |
| tree | 0337a9ba2b8dcf2f4004ac78d76e7c31ef84778a /src/util.h | |
| parent | e4f898c4a6b9900553c64b9804889b5fdae3e55f (diff) | |
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.
Diffstat (limited to 'src/util.h')
| -rw-r--r-- | src/util.h | 2 |
1 files changed, 1 insertions, 1 deletions
| @@ -199,7 +199,7 @@ protected: | |||
| 199 | public: | 199 | public: |
| 200 | char* pszFile; | 200 | char* pszFile; |
| 201 | int nLine; | 201 | int nLine; |
| 202 | explicit CCriticalSection() { InitializeCriticalSection(&cs); } | 202 | explicit CCriticalSection() : pszFile(NULL), nLine(0) { InitializeCriticalSection(&cs); } |
| 203 | ~CCriticalSection() { DeleteCriticalSection(&cs); } | 203 | ~CCriticalSection() { DeleteCriticalSection(&cs); } |
| 204 | void Enter() { EnterCriticalSection(&cs); } | 204 | void Enter() { EnterCriticalSection(&cs); } |
| 205 | void Leave() { LeaveCriticalSection(&cs); } | 205 | void Leave() { LeaveCriticalSection(&cs); } |