mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-07 08:15:59 -10:00
mg_start() calls InitializeCriticalSection(&global_log_file_lock) on every invocation, but mg_stop() never calls DeleteCriticalSection. Re-initializing an already-initialized critical section is undefined behavior on Windows and corrupts the heap, causing the next allocation to throw an exception. Make the Win32 initialization (WSAStartup + InitializeCriticalSection) one-shot via a static flag, and remove the asymmetric WSACleanup from mg_stop so resources remain valid across mg_start/mg_stop cycles. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>