summaryrefslogtreecommitdiff
path: root/ext/xsl/xsltprocessor.c
diff options
context:
space:
mode:
authorAaron Piotrowski <aaron@trowski.com>2016-06-10 22:02:23 -0500
committerAaron Piotrowski <aaron@trowski.com>2016-06-10 22:02:23 -0500
commite3c681aa5cc71122a8d2fae42e6513fc413ccac8 (patch)
tree5f1df62f7b666028edb0ee1adf083a52d63df45a /ext/xsl/xsltprocessor.c
parentfb4e3085cbaa76eb8f28eebf848a81d1c0190067 (diff)
parent792e89385ca6fc722a03590722eb7745a2374720 (diff)
downloadphp-git-e3c681aa5cc71122a8d2fae42e6513fc413ccac8.tar.gz
Merge branch 'master' into throw-error-in-extensions
Diffstat (limited to 'ext/xsl/xsltprocessor.c')
-rw-r--r--ext/xsl/xsltprocessor.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c
index f5a8fa8e33..5339812253 100644
--- a/ext/xsl/xsltprocessor.c
+++ b/ext/xsl/xsltprocessor.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2015 The PHP Group |
+ | Copyright (c) 1997-2016 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -153,7 +153,6 @@ static char **php_xsl_xslt_make_params(HashTable *parht, int xpath_params)
return NULL;
} else {
if (Z_TYPE_P(value) != IS_STRING) {
- SEPARATE_ZVAL(value);
convert_to_string(value);
}
@@ -218,7 +217,9 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
if (error == 1) {
for (i = nargs - 1; i >= 0; i--) {
obj = valuePop(ctxt);
- xmlXPathFreeObject(obj);
+ if (obj) {
+ xmlXPathFreeObject(obj);
+ }
}
return;
}
@@ -230,6 +231,10 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
/* Reverse order to pop values off ctxt stack */
for (i = nargs - 2; i >= 0; i--) {
obj = valuePop(ctxt);
+ if (obj == NULL) {
+ ZVAL_NULL(&args[i]);
+ continue;
+ }
switch (obj->type) {
case XPATH_STRING:
ZVAL_STRING(&args[i], (char *)obj->stringval);
@@ -266,7 +271,7 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
if (node->children) {
node = xmlNewDocNode(node->doc, NULL, (char *) node->children, node->name);
} else {
- node = xmlNewDocNode(node->doc, NULL, "xmlns", node->name);
+ node = xmlNewDocNode(node->doc, NULL, (const xmlChar *) "xmlns", node->name);
}
node->type = XML_NAMESPACE_DECL;
node->parent = nsparent;
@@ -282,7 +287,7 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
}
break;
default:
- str = xmlXPathCastToString(obj);
+ str = (char *) xmlXPathCastToString(obj);
ZVAL_STRING(&args[i], str);
xmlFree(str);
}
@@ -290,7 +295,6 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
}
fci.size = sizeof(fci);
- fci.function_table = EG(function_table);
if (fci.param_count > 0) {
fci.params = args;
} else {
@@ -299,10 +303,10 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
obj = valuePop(ctxt);
- if (obj->stringval == NULL) {
+ if (obj == NULL || obj->stringval == NULL) {
php_error_docref(NULL, E_WARNING, "Handler name must be a string");
xmlXPathFreeObject(obj);
- valuePush(ctxt, xmlXPathNewString(""));
+ valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));
if (fci.param_count > 0) {
for (i = 0; i < nargs - 1; i++) {
zval_ptr_dtor(&args[i]);
@@ -311,28 +315,27 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
}
return;
}
- ZVAL_STRING(&handler, obj->stringval);
+ ZVAL_STRING(&handler, (char *) obj->stringval);
xmlXPathFreeObject(obj);
ZVAL_COPY_VALUE(&fci.function_name, &handler);
- fci.symbol_table = NULL;
fci.object = NULL;
fci.retval = &retval;
fci.no_separation = 0;
/*fci.function_handler_cache = &function_ptr;*/
if (!zend_make_callable(&handler, &callable)) {
php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable));
- valuePush(ctxt, xmlXPathNewString(""));
+ valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));
} else if ( intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) {
php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'", ZSTR_VAL(callable));
/* Push an empty string, so that we at least have an xslt result... */
- valuePush(ctxt, xmlXPathNewString(""));
+ valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));
} else {
result = zend_call_function(&fci, NULL);
if (result == FAILURE) {
if (Z_TYPE(handler) == IS_STRING) {
php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", Z_STRVAL(handler));
- valuePush(ctxt, xmlXPathNewString(""));
+ valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));
}
/* retval is == NULL, when an exception occurred, don't report anything, because PHP itself will handle that */
} else if (Z_ISUNDEF(retval)) {
@@ -350,13 +353,13 @@ static void xsl_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int t
nodep = dom_object_get_node(obj);
valuePush(ctxt, xmlXPathNewNodeSet(nodep));
} else if (Z_TYPE(retval) == IS_TRUE || Z_TYPE(retval) == IS_FALSE) {
- valuePush(ctxt, xmlXPathNewBoolean(Z_LVAL(retval)));
+ valuePush(ctxt, xmlXPathNewBoolean(Z_TYPE(retval) == IS_TRUE));
} else if (Z_TYPE(retval) == IS_OBJECT) {
php_error_docref(NULL, E_WARNING, "A PHP Object cannot be converted to a XPath-string");
- valuePush(ctxt, xmlXPathNewString(""));
+ valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));
} else {
convert_to_string_ex(&retval);
- valuePush(ctxt, xmlXPathNewString(Z_STRVAL(retval)));
+ valuePush(ctxt, xmlXPathNewString((xmlChar *) Z_STRVAL(retval)));
}
zval_ptr_dtor(&retval);
}
@@ -445,7 +448,7 @@ PHP_FUNCTION(xsl_xsltprocessor_import_stylesheet)
nodep = xmlDocGetRootElement(sheetp->doc);
if (nodep && (nodep = nodep->children)) {
while (nodep) {
- if (nodep->type == XML_ELEMENT_NODE && xmlStrEqual(nodep->name, "key") && xmlStrEqual(nodep->ns->href, XSLT_NAMESPACE)) {
+ if (nodep->type == XML_ELEMENT_NODE && xmlStrEqual(nodep->name, (const xmlChar *) "key") && xmlStrEqual(nodep->ns->href, XSLT_NAMESPACE)) {
intern->hasKeys = 1;
break;
}
@@ -728,7 +731,7 @@ PHP_FUNCTION(xsl_xsltprocessor_transform_to_xml)
if (newdocp) {
ret = xsltSaveResultToString(&doc_txt_ptr, &doc_txt_len, newdocp, sheetp);
if (doc_txt_ptr && doc_txt_len) {
- RETVAL_STRINGL(doc_txt_ptr, doc_txt_len);
+ RETVAL_STRINGL((char *) doc_txt_ptr, doc_txt_len);
xmlFree(doc_txt_ptr);
}
xmlFreeDoc(newdocp);
@@ -748,7 +751,6 @@ PHP_FUNCTION(xsl_xsltprocessor_set_parameter)
zval *id;
zval *array_value, *entry, new_string;
xsl_object *intern;
- zend_ulong idx;
char *namespace;
size_t namespace_len;
zend_string *string_key, *name, *value;
@@ -756,12 +758,11 @@ PHP_FUNCTION(xsl_xsltprocessor_set_parameter)
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sa", &namespace, &namespace_len, &array_value) == SUCCESS) {
intern = Z_XSL_P(id);
- ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array_value), idx, string_key, entry) {
+ ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(array_value), string_key, entry) {
if (string_key == NULL) {
php_error_docref(NULL, E_WARNING, "Invalid parameter array");
RETURN_FALSE;
}
- SEPARATE_ZVAL(entry);
convert_to_string_ex(entry);
if (Z_REFCOUNTED_P(entry)) {
Z_ADDREF_P(entry);
@@ -849,7 +850,6 @@ PHP_FUNCTION(xsl_xsltprocessor_register_php_functions)
intern = Z_XSL_P(id);
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array_value), entry) {
- SEPARATE_ZVAL(entry);
convert_to_string_ex(entry);
ZVAL_LONG(&new_string ,1);
zend_hash_update(intern->registered_phpfunctions, Z_STR_P(entry), &new_string);