From 62c98f17dbe83f7fb61227efffc5edf77c4ef052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Wed, 11 Mar 2020 12:48:01 +1100 Subject: [PATCH] Fix invalid free for ipv6 --- lib/ProxySQL_Admin.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp index 1b93e7be1..c1a43dc0f 100644 --- a/lib/ProxySQL_Admin.cpp +++ b/lib/ProxySQL_Admin.cpp @@ -4652,9 +4652,10 @@ __end_while_pool: i=0; j=0; for (j=0; jifaces->len; j++) { char *add=NULL; char *port=NULL; char *sn=(char *)S_amll.ifaces_mysql->ifaces->index(j); - + bool is_ipv6 = false; char *h = NULL; if (*sn == '[') { + is_ipv6 = true; char *p = strchr(sn, ']'); if (p == NULL) proxy_error("Invalid IPv6 address: %s\n", sn); @@ -4674,8 +4675,10 @@ __end_while_pool: int s = ( atoi(port) ? listen_on_port(add, atoi(port), 128) : listen_on_unix(add, 128)); #endif if (s>0) { fds[nfds].fd=s; fds[nfds].events=POLLIN; fds[nfds].revents=0; callback_func[nfds]=0; socket_names[nfds]=strdup(sn); nfds++; } - if (add) free(add); - if (port) free(port); + if (is_ipv6 == false) { + if (add) free(add); + if (port) free(port); + } } S_amll.wrunlock(); }