diff --git a/ext/standard/dns.c b/ext/standard/dns.c index 269e03c1fc5..cf80fb48979 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -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 index 00000000000..531001b553b --- /dev/null +++ b/ext/standard/tests/network/getmxrr.phpt @@ -0,0 +1,16 @@ +--TEST-- +dns_check_record() segfault with empty host +--FILE-- + +--EXPECT-- +Hosts: 2, weights: 2 +Hosts: 1, weights: 1