Skip to content

Commit 79d649e

Browse files
committed
fix memleak when connection fails (and we still keep trying)
1 parent cf0c7a9 commit 79d649e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

main/network.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,13 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
817817
bad_ip:
818818
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid IP Address: %s", bindto);
819819
}
820-
bind_done:
820+
bind_done:
821+
/* free error string recieved during previous iteration (if any) */
822+
if (error_string && *error_string) {
823+
efree(*error_string);
824+
*error_string = NULL;
825+
}
826+
821827
n = php_network_connect_socket(sock, sa, socklen, asynchronous,
822828
timeout ? &working_timeout : NULL,
823829
error_string, error_code);

0 commit comments

Comments
 (0)