summaryrefslogtreecommitdiff
path: root/main/network.c
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2008-03-11 10:27:10 +0000
committerAntony Dovgal <tony2001@php.net>2008-03-11 10:27:10 +0000
commitf0b9ac513c3c65460759951929a7cf8e6531e74e (patch)
treecda3ab52990c1871d06b59a820e3490a1f78947a /main/network.c
parente897db28bf6ff1f50cbb0d0459929ac9dd27fc7c (diff)
downloadphp-git-f0b9ac513c3c65460759951929a7cf8e6531e74e.tar.gz
MFH: fix segfault - error_string may be NULL, in this case we have to follow the old behavior
Diffstat (limited to 'main/network.c')
-rw-r--r--main/network.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/main/network.c b/main/network.c
index db4fc7bd80..fd0d3161ce 100644
--- a/main/network.c
+++ b/main/network.c
@@ -205,12 +205,20 @@ static int php_network_getaddresses(const char *host, int socktype, struct socka
# endif
if ((n = getaddrinfo(host, NULL, &hints, &res))) {
- spprintf(error_string, 0, "php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", *error_string);
+ if (error_string) {
+ spprintf(error_string, 0, "php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", *error_string);
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: getaddrinfo failed: %s", PHP_GAI_STRERROR(n));
+ }
return 0;
} else if (res == NULL) {
- spprintf(error_string, 0, "php_network_getaddresses: getaddrinfo failed (null result pointer) errno=%d", errno);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", *error_string);
+ if (error_string) {
+ spprintf(error_string, 0, "php_network_getaddresses: getaddrinfo failed (null result pointer) errno=%d", errno);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", *error_string);
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: getaddrinfo failed (null result pointer)");
+ }
return 0;
}
@@ -234,8 +242,12 @@ static int php_network_getaddresses(const char *host, int socktype, struct socka
/* XXX NOT THREAD SAFE (is safe under win32) */
host_info = gethostbyname(host);
if (host_info == NULL) {
- spprintf(error_string, 0, "php_network_getaddresses: gethostbyname failed. errno=%d", errno);
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", *error_string);
+ if (error_string) {
+ spprintf(error_string, 0, "php_network_getaddresses: gethostbyname failed. errno=%d", errno);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", *error_string);
+ } else {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_network_getaddresses: gethostbyname failed");
+ }
return 0;
}
in = *((struct in_addr *) host_info->h_addr);