MDEV-10455: libmariadbclient18 + MySQL-python leaks memory on failed connections

Support of CLIENT_REMEMBER_OPTIONS and freeing options added.
This commit is contained in:
Oleksandr Byelkin 2016-08-11 17:50:21 +02:00
parent b5fb2a685b
commit 66ac894c40
2 changed files with 4 additions and 2 deletions

View File

@ -3644,6 +3644,8 @@ error:
/* Free alloced memory */ /* Free alloced memory */
end_server(mysql); end_server(mysql);
mysql_close_free(mysql); mysql_close_free(mysql);
if (!(client_flag & CLIENT_REMEMBER_OPTIONS))
mysql_close_free_options(mysql);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
@ -3714,7 +3716,7 @@ my_bool mysql_reconnect(MYSQL *mysql)
} }
if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd, if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
mysql->db, mysql->port, mysql->unix_socket, mysql->db, mysql->port, mysql->unix_socket,
mysql->client_flag)) mysql->client_flag | CLIENT_REMEMBER_OPTIONS))
{ {
if (ctxt) if (ctxt)
my_context_install_suspend_resume_hook(ctxt, NULL, NULL); my_context_install_suspend_resume_hook(ctxt, NULL, NULL);

View File

@ -6061,7 +6061,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi,
#ifndef DBUG_OFF #ifndef DBUG_OFF
mi->events_till_disconnect = disconnect_slave_event_count; mi->events_till_disconnect = disconnect_slave_event_count;
#endif #endif
ulong client_flag= 0; ulong client_flag= CLIENT_REMEMBER_OPTIONS;
if (opt_slave_compressed_protocol) if (opt_slave_compressed_protocol)
client_flag=CLIENT_COMPRESS; /* We will use compression */ client_flag=CLIENT_COMPRESS; /* We will use compression */