Skip to content

Commit 300746d

Browse files
committed
Introduce Z_PARAM_GET_PREV_ZVAL()
1 parent f6651b7 commit 300746d

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

Zend/zend_API.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,10 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *
14821482
SEPARATE_ZVAL_NOREF(_arg); \
14831483
}
14841484

1485+
/* get the zval* for a previously parsed argument */
1486+
#define Z_PARAM_GET_PREV_ZVAL(dest) \
1487+
zend_parse_arg_zval_deref(_arg, &dest, 0);
1488+
14851489
/* old "|" */
14861490
#define Z_PARAM_OPTIONAL \
14871491
_optional = 1;

ext/libxml/libxml.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,24 +1064,17 @@ PHP_FUNCTION(libxml_set_external_entity_loader)
10641064
zval *callback;
10651065
zend_fcall_info fci;
10661066
zend_fcall_info_cache fcc;
1067-
char *error = NULL;
10681067

10691068
ZEND_PARSE_PARAMETERS_START(1, 1)
1070-
Z_PARAM_ZVAL(callback)
1069+
Z_PARAM_FUNC_OR_NULL(fci, fcc)
1070+
Z_PARAM_GET_PREV_ZVAL(callback)
10711071
ZEND_PARSE_PARAMETERS_END();
10721072

1073-
if (Z_ISNULL_P(callback)) {
1074-
LIBXML(entity_loader).fci.size = 0;
1075-
} else {
1076-
fci.size = sizeof(fci);
1077-
fci.object = NULL;
1078-
fci.named_params = NULL;
1079-
if (zend_fcall_info_init(callback, 0, &fci, &fcc, NULL, &error) != SUCCESS) {
1080-
zend_argument_type_error(1, "must be a valid callback or null, %s", error);
1081-
RETURN_THROWS();
1082-
}
1073+
if (ZEND_FCI_INITIALIZED(fci)) { /* argument not null */
10831074
LIBXML(entity_loader).fci = fci;
10841075
LIBXML(entity_loader).fcc = fcc;
1076+
} else {
1077+
LIBXML(entity_loader).fci.size = 0;
10851078
}
10861079
if (!Z_ISNULL(LIBXML(entity_loader).callback)) {
10871080
zval_ptr_dtor_nogc(&LIBXML(entity_loader).callback);

ext/libxml/tests/libxml_set_external_entity_loader_error2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--TEST--
22
libxml_set_external_entity_loader() with non-callable argument
33
--EXTENSIONS--
4-
dom
4+
libxml
55
--FILE--
66
<?php
77
try {

0 commit comments

Comments
 (0)