]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commit
Fix Windows-specific use-after-free causing crash after disconnecting
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 23 May 2020 22:22:30 +0000 (22:22 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 23 May 2020 22:22:30 +0000 (22:22 +0000)
commit46acef5491629d06eddb8e78ed01e50b175d2bd8
tree84a55b6033c5cb513c75e27ce57abce0a93a72b3
parent3e57e7974c6e04e66a3f9d89629433fb5fa44e21
Fix Windows-specific use-after-free causing crash after disconnecting

This explicitly deregisters CSQC commands every time CSQC shuts down. This patch
also avoids Z_Malloc'ing the cmd names for each CSQC command and avoids forcing
a Cmd_AddCommand if the command exists.

CSQC was force-adding a command even if it already existed, and when it did,
it would pass a pointer from a mempool that would later get freed when
CSQC shuts down, and Windows' strcasecmp doesn't like dangling pointers.
The Z_Malloc wasn't much better because it could have caused a memory leak.
So the best solution was to only pass the pointer but make sure the commands
are freed when CSQC shuts down.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12558 d7cf8633-e32d-0410-b094-e92efae38249
clvm_cmds.c
cmd.c
cmd.h
csprogs.c
sbar.c