List:Commits« Previous MessageNext Message »
From:Frazer Clement Date:January 15 2009 2:33pm
Subject:bzr commit into mysql-5.1 branch (frazer:3213)
View as plain text  
#At file:///home/frazer/bzr/mysql-5.1-telco-6.4-ipv6/

 3213 Frazer Clement	2009-01-15
      WL4562 IPv6 replication support
      
      Code review comments.
      
      - Free addrinfo structure on getaddrinfo error path as 
        function documents no guarantee. 
      - Remove unneeded temporary.
modified:
  sql-common/client.c
  sql/hostname.cc

=== modified file 'sql-common/client.c'
--- a/sql-common/client.c	2009-01-13 11:40:15 +0000
+++ b/sql-common/client.c	2009-01-15 14:33:25 +0000
@@ -2020,7 +2020,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,cons
       (!mysql->options.protocol ||
        mysql->options.protocol == MYSQL_PROTOCOL_TCP))
   {
-    struct addrinfo *res_lst, hints, *t_res;
+    struct addrinfo *res_lst= NULL, hints;
     int gai_errno;
     char port_buf[NI_MAXSERV];
  
@@ -2060,16 +2060,18 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,cons
       DBUG_PRINT("info",("getaddrinfo error %d", gai_errno));
       set_mysql_extended_error(mysql, CR_UNKNOWN_HOST, unknown_sqlstate,
                                ER(CR_UNKNOWN_HOST), host, errno);
+      
+      if (res_lst)
+        freeaddrinfo(res_lst);
 
       goto error;
     }
 
     /* We only look at the first item (something to think about changing in the future) */
-    t_res= res_lst; 
     {
       DBUG_PRINT("info",("Creating socket : Family %d, Type %d, Protocol %d",
-                         t_res->ai_family, t_res->ai_socktype, t_res->ai_protocol));
-      sock= my_socket_create(t_res->ai_family, t_res->ai_socktype, t_res->ai_protocol);
+                         res_lst->ai_family, res_lst->ai_socktype, res_lst->ai_protocol));
+      sock= my_socket_create(res_lst->ai_family, res_lst->ai_socktype, res_lst->ai_protocol);
       if (!my_socket_valid(sock))
       {
         DBUG_PRINT("info",("Socket created was invalid"));
@@ -2100,6 +2102,10 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,cons
           DBUG_PRINT("info",("getaddrinfo error %d", gai_errno));
           set_mysql_extended_error(mysql, CR_UNKNOWN_HOST, unknown_sqlstate,
                                    ER(CR_UNKNOWN_HOST), mysql->options.bind_name, errno);
+
+          if (clientBindAddrInfo)
+            freeaddrinfo(clientBindAddrInfo);
+          
           freeaddrinfo(res_lst);
           goto error;
         }
@@ -2149,7 +2155,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,cons
         goto error;
       }
 
-      if (my_connect(MY_SOCKET_FORMAT_VALUE(sock), t_res->ai_addr, t_res->ai_addrlen,
+      if (my_connect(MY_SOCKET_FORMAT_VALUE(sock), res_lst->ai_addr, res_lst->ai_addrlen,
                      mysql->options.connect_timeout))
       {
         DBUG_PRINT("error",("Got error %d on connect to '%s'",socket_errno,

=== modified file 'sql/hostname.cc'
--- a/sql/hostname.cc	2009-01-08 17:44:55 +0000
+++ b/sql/hostname.cc	2009-01-15 14:33:25 +0000
@@ -138,7 +138,7 @@ char * ip_to_hostname(struct sockaddr_st
 {
   char *name= NULL;
 
-  struct addrinfo hints,*res_lst,*t_res;
+  struct addrinfo hints,*res_lst= NULL,*t_res;
   int gxi_error;
   char hostname_buff[NI_MAXHOST];
 
@@ -232,6 +232,9 @@ char * ip_to_hostname(struct sockaddr_st
 #endif
       add_wrong_ip(in);
 
+    if (res_lst)
+      freeaddrinfo(res_lst);
+
     my_free(name, MYF(0));
     DBUG_RETURN(0);
   }

Thread
bzr commit into mysql-5.1 branch (frazer:3213) Frazer Clement15 Jan