From f993402c625dd6be5efc5d2f924b90029f280e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Fri, 9 Sep 2022 22:50:40 +0200 Subject: [PATCH] Fix crash when failed 'connection_reset' is tried to be logged --- lib/MySQL_Logger.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/MySQL_Logger.cpp b/lib/MySQL_Logger.cpp index 9a520885a..dfe63da34 100644 --- a/lib/MySQL_Logger.cpp +++ b/lib/MySQL_Logger.cpp @@ -626,6 +626,9 @@ void MySQL_Logger::audit_set_datadir(char *s) { void MySQL_Logger::log_request(MySQL_Session *sess, MySQL_Data_Stream *myds) { if (events.enabled==false) return; if (events.logfile==NULL) return; + // 'MySQL_Session::client_myds' could be NULL in case of 'RequestEnd' being called over a freshly created session + // due to a failed 'CONNECTION_RESET'. Because this scenario isn't a client request, we just return. + if (sess->client_myds==NULL || sess->client_myds->myconn== NULL) return; MySQL_Connection_userinfo *ui=sess->client_myds->myconn->userinfo;