tony2001                Tue Mar 11 10:26:51 2008 UTC

  Modified files:              
    /php-src/main       network.c 
  Log:
  fix segfault - error_string may be NULL, in this case we have to follow the 
old behavior
  
  
http://cvs.php.net/viewvc.cgi/php-src/main/network.c?r1=1.132&r2=1.133&diff_format=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.132 php-src/main/network.c:1.133
--- php-src/main/network.c:1.132        Mon Mar 10 19:55:43 2008
+++ php-src/main/network.c      Tue Mar 11 10:26:51 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: network.c,v 1.132 2008/03/10 19:55:43 andrey Exp $ */
+/* $Id: network.c,v 1.133 2008/03/11 10:26:51 tony2001 Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -205,12 +205,20 @@
 # 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 @@
                /* 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);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to