diff options
Diffstat (limited to 'main/network.c')
-rw-r--r-- | main/network.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/main/network.c b/main/network.c index 3c8e81cc81..8035adb195 100644 --- a/main/network.c +++ b/main/network.c @@ -200,6 +200,10 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka if ((n = getaddrinfo(host, NULL, &hints, &res))) { if (error_string) { + /* free error string received during previous iteration (if any) */ + if (*error_string) { + zend_string_release_ex(*error_string, 0); + } *error_string = strpprintf(0, "php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n)); php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(*error_string)); } else { @@ -208,6 +212,10 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka return 0; } else if (res == NULL) { if (error_string) { + /* free error string received during previous iteration (if any) */ + if (*error_string) { + zend_string_release_ex(*error_string, 0); + } *error_string = strpprintf(0, "php_network_getaddresses: getaddrinfo failed (null result pointer) errno=%d", errno); php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(*error_string)); } else { @@ -241,6 +249,10 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka } if (host_info == NULL) { if (error_string) { + /* free error string received during previous iteration (if any) */ + if (*error_string) { + zend_string_release_ex(*error_string, 0); + } *error_string = strpprintf(0, "php_network_getaddresses: gethostbyname failed. errno=%d", errno); php_error_docref(NULL, E_WARNING, "%s", ZSTR_VAL(*error_string)); } else { |