Commit f064cd84 authored by svoj@mysql.com/june.mysql.com's avatar svoj@mysql.com/june.mysql.com
Browse files

BUG#35509 - Federated leaks memory when connecting to

            localhost/default port

When creating federated table that points to unspecified host or
localhost on unspecified port or port is 0, small memory leak occurs.

This happens because we make a copy of unix socket path, which is
never freed.

With this fix we do not make a copy of unix socket path, instead
share->socket points to MYSQL_UNIX_ADDR constant directly.

This fix is covered by a test case for BUG34788.

Affects 5.0 only.
parent 2b552aae
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1742,6 +1742,11 @@ DROP TABLE t1;
# BUG#34788 - malformed federated connection url is not handled correctly -
#             crashes server !
#
# also tests
#
# BUG#35509 - Federated leaks memory when connecting to localhost/default
#             port
#
CREATE TABLE t1 (a INT) ENGINE=federated CONNECTION='mysql://@:://';
DROP TABLE t1;

+1 −2
Original line number Diff line number Diff line
@@ -656,7 +656,7 @@ static int parse_url(FEDERATED_SHARE *share, TABLE *table,
  if (!share->port)
  {
    if (!share->hostname || strcmp(share->hostname, my_localhost) == 0)
      share->socket= my_strdup(MYSQL_UNIX_ADDR, MYF(0));
      share->socket= (char*) MYSQL_UNIX_ADDR;
    else
      share->port= MYSQL_PORT;
  }
@@ -1342,7 +1342,6 @@ static int free_share(FEDERATED_SHARE *share)
  {
    hash_delete(&federated_open_tables, (byte*) share);
    my_free((gptr) share->scheme, MYF(MY_ALLOW_ZERO_PTR));
    my_free((gptr) share->socket, MYF(MY_ALLOW_ZERO_PTR));
    thr_lock_delete(&share->lock);
    VOID(pthread_mutex_destroy(&share->mutex));
    my_free((gptr) share, MYF(0));