From 4b28bb6ced01fa4fb82482b6081fe41080d92bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Thu, 30 Oct 2025 12:05:07 +0100 Subject: [PATCH] Fix heap-after-use between 'PROXYSQL INTERNAL SESSION' and 'SHOW PROCESSLIST' Missing query cleanup in 'PROXYSQL INTERNAL SESSION' could lead to invalid memory accesses during 'SHOW PROCESSLIST' sessions scan. --- lib/Base_Session.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Base_Session.cpp b/lib/Base_Session.cpp index 55b1250b3..e9f5bc112 100644 --- a/lib/Base_Session.cpp +++ b/lib/Base_Session.cpp @@ -304,6 +304,8 @@ void Base_Session::return_proxysql_internal(PtrSize_t* pkt) { bool deprecate_eof_active = client_myds->myconn->options.client_flag & CLIENT_DEPRECATE_EOF; SQLite3_to_MySQL(resultset, NULL, 0, &client_myds->myprot, false, deprecate_eof_active); delete resultset; + // NOTE: End request before freeing the packet; otherwise logging could use invalid memory + static_cast(this)->RequestEnd(NULL); l_free(pkt->size, pkt->ptr); return; } @@ -331,6 +333,8 @@ void Base_Session::return_proxysql_internal(PtrSize_t* pkt) { char txn_state = (nTxn ? 'T' : 'I'); SQLite3_to_Postgres(client_myds->PSarrayOUT, resultset, nullptr, 0, (const char*)pkt->ptr + 5, txn_state); delete resultset; + // NOTE: End request before freeing the packet; otherwise logging could use invalid memory + static_cast(this)->RequestEnd(NULL, false); l_free(pkt->size, pkt->ptr); return; }