From d5d330f82a54d23ef16fdbd3579e40e1a8364743 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 27 May 2025 16:18:50 +1000 Subject: [PATCH] mariadb_reconnect: reconnection may fail to allocate extensions If this the case, tmp_mysql.extensions will be a null pointer and the rest of the reconnection cannot continue. --- libmariadb/mariadb_lib.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index 5122166c..bb99384f 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -2111,7 +2111,14 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql) return(1); } - mysql_init(&tmp_mysql); + if (!mysql_init(&tmp_mysql)) + { + /* extensions may have failed to allocate */ + SET_CLIENT_ERROR(mysql, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0); + tmp_mysql.free_me= 0; + mysql_close(&tmp_mysql); + return(1); + } tmp_mysql.free_me= 0; tmp_mysql.options=mysql->options; if (mysql->extension->conn_hdlr)