Skip to content

Commit bbaee1a

Browse files
committed
Promote warning to exception in dns_check_record() function
phpGH-5004
1 parent 269f44f commit bbaee1a

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

ext/standard/dns.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ PHP_FUNCTION(dns_check_record)
383383
ZEND_PARSE_PARAMETERS_END();
384384

385385
if (hostname_len == 0) {
386-
php_error_docref(NULL, E_WARNING, "Host cannot be empty");
387-
RETURN_FALSE;
386+
zend_value_error("Host cannot be empty");
387+
return;
388388
}
389389

390390
if (rectype) {

ext/standard/dns_win32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ PHP_FUNCTION(dns_check_record)
107107
}
108108

109109
if (hostname_len == 0) {
110-
php_error_docref(NULL, E_WARNING, "Host cannot be empty");
111-
RETURN_FALSE;
110+
zend_value_error("Host cannot be empty");
111+
return;
112112
}
113113

114114
if (rectype) {

ext/standard/tests/network/bug41347.phpt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
dns_check_record() segfault with empty host
33
--FILE--
44
<?php
5-
var_dump(dns_check_record(''));
5+
try {
6+
var_dump(dns_check_record(''));
7+
} catch (ValueError $exception) {
8+
echo $exception->getMessage() . "\n";
9+
}
610
?>
7-
--EXPECTF--
8-
Warning: dns_check_record(): Host cannot be empty in %s on line %d
9-
bool(false)
11+
--EXPECT--
12+
Host cannot be empty

0 commit comments

Comments
 (0)