Skip to content

Commit 3a44824

Browse files
committed
Fix argument number, add test. Use RETURN_THROWS().
1 parent 0749e60 commit 3a44824

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

ext/libxml/libxml.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,8 @@ PHP_FUNCTION(libxml_set_external_entity_loader)
10791079
fci.object = NULL;
10801080
fci.named_params = NULL;
10811081
if (zend_fcall_info_init(callback, 0, &fci, &fcc, NULL, &error) != SUCCESS) {
1082-
zend_argument_type_error(0, "must be a valid callback or NULL, %s", error);
1083-
RETURN_FALSE;
1082+
zend_argument_type_error(1, "must be a valid callback or NULL, %s", error);
1083+
RETURN_THROWS();
10841084
}
10851085
LIBXML(entity_loader).fci = fci;
10861086
LIBXML(entity_loader).fcc = fcc;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
libxml_set_external_entity_loader() with non-callable argument
3+
--EXTENSIONS--
4+
dom
5+
--FILE--
6+
<?php
7+
try {
8+
libxml_set_external_entity_loader('nonexistent_function');
9+
} catch (Throwable $e) {
10+
echo "Exception: " . $e->getMessage() . "\n";
11+
}
12+
?>
13+
--EXPECT--
14+
Exception: libxml_set_external_entity_loader(): Argument #1 ($resolver_function) must be a valid callback or NULL, function "nonexistent_function" not found or invalid function name

0 commit comments

Comments
 (0)