From 258584ff6d5da2462090edb9cd600dc0a212ee95 Mon Sep 17 00:00:00 2001 From: Ilya Eremin Date: Wed, 21 Aug 2024 10:23:03 +0300 Subject: [PATCH] Fix a case of deleted memory modification cnctAuth and port->port_srv_auth point to the same object so useResponse must not be assigned if the object is deleted. --- src/remote/server/server.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/remote/server/server.cpp b/src/remote/server/server.cpp index 8d62159283..668bf50a93 100644 --- a/src/remote/server/server.cpp +++ b/src/remote/server/server.cpp @@ -2014,13 +2014,15 @@ static bool accept_connection(rem_port* port, P_CNCT* connect, PACKET* send) { ConnectAuth* cnctAuth = FB_NEW ConnectAuth(port, id); port->port_srv_auth = cnctAuth; - if (port->port_srv_auth->authenticate(send, ServerAuth::AUTH_COND_ACCEPT)) + + if (cnctAuth->authenticate(send, ServerAuth::AUTH_COND_ACCEPT)) { - delete port->port_srv_auth; + delete cnctAuth; port->port_srv_auth = NULL; } + else + cnctAuth->useResponse = true; - cnctAuth->useResponse = true; return true; }