Fix memory leak in dbusers.c

The MySQL connection was created twice.
This commit is contained in:
Markus Mäkelä
2017-01-30 12:48:21 +02:00
parent b376d9043a
commit ba16b8ca1c

View File

@ -1953,12 +1953,11 @@ int get_users_from_server(MYSQL *con, SERVER_REF *server, SERVICE *service, SERV
*/ */
static int get_users(SERV_LISTENER *listener, USERS *users) static int get_users(SERV_LISTENER *listener, USERS *users)
{ {
MYSQL *con = gw_mysql_init();
char *service_user = NULL; char *service_user = NULL;
char *service_passwd = NULL; char *service_passwd = NULL;
SERVICE *service = listener->service; SERVICE *service = listener->service;
if (con == NULL || serviceGetUser(service, &service_user, &service_passwd) == 0) if (serviceGetUser(service, &service_user, &service_passwd) == 0)
{ {
return -1; return -1;
} }
@ -1975,7 +1974,7 @@ static int get_users(SERV_LISTENER *listener, USERS *users)
for (server = service->dbref; !service->svc_do_shutdown && server; server = server->next) for (server = service->dbref; !service->svc_do_shutdown && server; server = server->next)
{ {
con = gw_mysql_init(); MYSQL *con = gw_mysql_init();
if (con) if (con)
{ {
if (mxs_mysql_real_connect(con, server->server, service_user, dpwd) == NULL) if (mxs_mysql_real_connect(con, server->server, service_user, dpwd) == NULL)