summaryrefslogtreecommitdiff
path: root/ext/simplexml/simplexml.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/simplexml/simplexml.c')
-rw-r--r--ext/simplexml/simplexml.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 0637e06af8..50413b12ac 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -247,8 +247,8 @@ static zval *sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, z
if (!member) {
if (sxe->iter.type == SXE_ITER_ATTRLIST) {
/* This happens when the user did: $sxe[]->foo = $value */
- php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute");
- return NULL;
+ zend_throw_error(NULL, "Cannot create unnamed attribute");
+ return &EG(uninitialized_zval);
}
goto long_dim;
} else {
@@ -284,8 +284,8 @@ long_dim:
if (!member && node && node->parent &&
node->parent->type == XML_DOCUMENT_NODE) {
/* This happens when the user did: $sxe[]->foo = $value */
- php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute");
- return NULL;
+ zend_throw_error(NULL, "Cannot create unnamed attribute");
+ return &EG(uninitialized_zval);
}
}
@@ -330,7 +330,7 @@ long_dim:
}
if (sxe->iter.type == SXE_ITER_NONE) {
if (member && Z_LVAL_P(member) > 0) {
- php_error_docref(NULL, E_WARNING, "Cannot add element %s number %pd when only 0 such elements exist", mynode->name, Z_LVAL_P(member));
+ php_error_docref(NULL, E_WARNING, "Cannot add element %s number " ZEND_LONG_FMT " when only 0 such elements exist", mynode->name, Z_LVAL_P(member));
}
} else if (member) {
node = sxe_get_element_by_offset(sxe, Z_LVAL_P(member), node, &cnt);
@@ -341,7 +341,7 @@ long_dim:
_node_as_zval(sxe, node, rv, SXE_ITER_NONE, NULL, sxe->iter.nsprefix, sxe->iter.isprefix);
} else if (type == BP_VAR_W || type == BP_VAR_RW) {
if (member && cnt < Z_LVAL_P(member)) {
- php_error_docref(NULL, E_WARNING, "Cannot add element %s number %pd when only %pd such elements exist", mynode->name, Z_LVAL_P(member), cnt);
+ php_error_docref(NULL, E_WARNING, "Cannot add element %s number " ZEND_LONG_FMT " when only " ZEND_LONG_FMT " such elements exist", mynode->name, Z_LVAL_P(member), cnt);
}
node = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, NULL);
_node_as_zval(sxe, node, rv, SXE_ITER_NONE, NULL, sxe->iter.nsprefix, sxe->iter.isprefix);
@@ -466,7 +466,7 @@ static int sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool
* and could also be E_PARSE, but we use this only during parsing
* and this is during runtime.
*/
- php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute");
+ zend_throw_error(NULL, "Cannot create unnamed attribute");
return FAILURE;
}
goto long_dim;
@@ -515,7 +515,7 @@ long_dim:
* and could also be E_PARSE, but we use this only during parsing
* and this is during runtime.
*/
- php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute");
+ zend_throw_error(NULL, "Cannot create unnamed attribute");
return FAILURE;
}
if (attribs && !node && sxe->iter.type == SXE_ITER_ELEMENT) {
@@ -588,7 +588,10 @@ long_dim:
if (elements) {
if (!member || Z_TYPE_P(member) == IS_LONG) {
if (node->type == XML_ATTRIBUTE_NODE) {
- php_error_docref(NULL, E_ERROR, "Cannot create duplicate attribute");
+ zend_throw_error(NULL, "Cannot create duplicate attribute");
+ if (new_value) {
+ zval_ptr_dtor(value);
+ }
return FAILURE;
}
@@ -596,7 +599,7 @@ long_dim:
newnode = node;
++counter;
if (member && Z_LVAL_P(member) > 0) {
- php_error_docref(NULL, E_WARNING, "Cannot add element %s number %pd when only 0 such elements exist", mynode->name, Z_LVAL_P(member));
+ php_error_docref(NULL, E_WARNING, "Cannot add element %s number " ZEND_LONG_FMT " when only 0 such elements exist", mynode->name, Z_LVAL_P(member));
retval = FAILURE;
}
} else if (member) {
@@ -644,14 +647,14 @@ next_iter:
}
} else if (!member || Z_TYPE_P(member) == IS_LONG) {
if (member && cnt < Z_LVAL_P(member)) {
- php_error_docref(NULL, E_WARNING, "Cannot add element %s number %pd when only %pd such elements exist", mynode->name, Z_LVAL_P(member), cnt);
+ php_error_docref(NULL, E_WARNING, "Cannot add element %s number " ZEND_LONG_FMT " when only " ZEND_LONG_FMT " such elements exist", mynode->name, Z_LVAL_P(member), cnt);
retval = FAILURE;
}
newnode = xmlNewTextChild(mynode->parent, mynode->ns, mynode->name, value ? (xmlChar *)Z_STRVAL_P(value) : NULL);
}
} else if (attribs) {
if (Z_TYPE_P(member) == IS_LONG) {
- php_error_docref(NULL, E_WARNING, "Cannot change attribute number %pd when only %d attributes exist", Z_LVAL_P(member), nodendx);
+ php_error_docref(NULL, E_WARNING, "Cannot change attribute number " ZEND_LONG_FMT " when only %d attributes exist", Z_LVAL_P(member), nodendx);
retval = FAILURE;
} else {
newnode = (xmlNodePtr)xmlNewProp(node, (xmlChar *)Z_STRVAL_P(member), value ? (xmlChar *)Z_STRVAL_P(value) : NULL);
@@ -713,7 +716,6 @@ static zval *sxe_property_get_adr(zval *object, zval *member, int fetch_type, vo
_node_as_zval(sxe, node, &ret, type, name, sxe->iter.nsprefix, sxe->iter.isprefix);
- sxe = Z_SXEOBJ_P(&ret);
if (!Z_ISUNDEF(sxe->tmp)) {
zval_ptr_dtor(&sxe->tmp);
}
@@ -1988,12 +1990,8 @@ static int sxe_count_elements(zval *object, zend_long *count) /* {{{ */
zval rv;
zend_call_method_with_0_params(object, intern->zo.ce, &intern->fptr_count, "count", &rv);
if (!Z_ISUNDEF(rv)) {
- if (!Z_ISUNDEF(intern->tmp)) {
- zval_ptr_dtor(&intern->tmp);
- }
- ZVAL_LONG(&intern->tmp, zval_get_long(&rv));
+ *count = zval_get_long(&rv);
zval_ptr_dtor(&rv);
- *count = Z_LVAL(intern->tmp);
return SUCCESS;
}
return FAILURE;
@@ -2053,7 +2051,9 @@ static zend_object_handlers sxe_object_handlers = { /* {{{ */
sxe_count_elements,
sxe_get_debug_info,
NULL,
- sxe_get_gc
+ sxe_get_gc,
+ NULL,
+ NULL
};
/* }}} */
@@ -2355,6 +2355,7 @@ zend_object_iterator_funcs php_sxe_iterator_funcs = { /* {{{ */
php_sxe_iterator_current_key,
php_sxe_iterator_move_forward,
php_sxe_iterator_rewind,
+ NULL
};
/* }}} */