]> granicus.if.org Git - php/commitdiff
- Fixed weights array, which was broken with:
authorDerick Rethans <derick@php.net>
Thu, 22 Nov 2007 10:18:30 +0000 (10:18 +0000)
committerDerick Rethans <derick@php.net>
Thu, 22 Nov 2007 10:18:30 +0000 (10:18 +0000)
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/dns.c?r1=1.80&r2=1.81

ext/standard/dns.c
ext/standard/tests/network/getmxrr.phpt [new file with mode: 0644]

index 269e03c1fc5b17f97f333f4034ea3874dd29e7e2..cf80fb489798069696c7da01d738b31093bd8da6 100644 (file)
@@ -836,7 +836,6 @@ PHP_FUNCTION(dns_get_mx)
        char *hostname;
        int hostname_len;
        zval *mx_list, *weight_list = NULL;
-       int need_weight = 0;
        int count, qdc;
        u_short type, weight;
        u_char ans[MAXPACKET];
@@ -891,7 +890,7 @@ PHP_FUNCTION(dns_get_mx)
                }
                cp += i;
                add_next_index_rt_string(mx_list, buf, ZSTR_DUPLICATE);
-               if (need_weight) {
+               if (weight_list) {
                        add_next_index_long(weight_list, weight);
                }
        }
diff --git a/ext/standard/tests/network/getmxrr.phpt b/ext/standard/tests/network/getmxrr.phpt
new file mode 100644 (file)
index 0000000..531001b
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+dns_check_record() segfault with empty host
+--FILE--
+<?php
+$domains = array( 'php.net', 'ez.no' );
+foreach ( $domains as $domain )
+{
+    if ( getmxrr( $domain, $hosts, $weights ) )
+    {
+        echo "Hosts: " . count( $hosts ) . ", weights: " . count( $weights ) . "\n";
+    }
+}
+?>
+--EXPECT--
+Hosts: 2, weights: 2
+Hosts: 1, weights: 1