summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-06-03 22:07:44 +0200
committerGitHub <noreply@github.com>2021-06-03 22:07:44 +0200
commit5e44da30101769a177c9cab654336a31c93df09b (patch)
tree7ad0306fa67c0d27daa7c65e4286bff7a13156fc
parentfeb2ddbefa5f6f702b996b00dfd92db53a52d174 (diff)
downloadopenttd-5e44da30101769a177c9cab654336a31c93df09b.tar.xz
Fix ef991b17: server was trying to free() a packet created with "new CommandPacket()" (#9334)
-rw-r--r--src/network/network.cpp2
-rw-r--r--src/network/network_server.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index d89789cf9..862169c1d 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -1072,7 +1072,7 @@ void NetworkGameLoop()
if (cp != nullptr) {
NetworkSendCommand(cp->tile, cp->p1, cp->p2, cp->cmd & ~CMD_FLAGS_MASK, nullptr, cp->text, cp->company);
DEBUG(desync, 0, "Injecting: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text.c_str(), GetCommandName(cp->cmd));
- free(cp);
+ delete cp;
cp = nullptr;
}
if (check_sync_state) {
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 49b1c8faf..5b1da8fa2 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -1758,7 +1758,7 @@ static void NetworkHandleCommandQueue(NetworkClientSocket *cs)
CommandPacket *cp;
while ((cp = cs->outgoing_queue.Pop()) != nullptr) {
cs->SendCommand(cp);
- free(cp);
+ delete cp;
}
}