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

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

index 6c7a629bcc92c715baf81a907c42b0af492b27af..5854fab3668e6332770a7a2aa3ce9714c4f9df95 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_string(mx_list, buf, 1);
-               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