diff options
Diffstat (limited to 'ext/simplexml')
-rw-r--r-- | ext/simplexml/simplexml.c | 17 | ||||
-rw-r--r-- | ext/simplexml/tests/012.phpt | 5 |
2 files changed, 14 insertions, 8 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 8a1ef4915f..d848fcac16 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -250,8 +250,8 @@ static zval *sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, z elements = 1; } else if (!member) { /* This happens when the user did: $sxe[]->foo = $value */ - php_error_docref(NULL, E_ERROR, "Cannot create unnamed attribute"); - return NULL; + zend_throw_error(zend_ce_error, "Cannot create unnamed attribute"); + return &EG(uninitialized_zval); } name = NULL; } else { @@ -277,8 +277,8 @@ static zval *sxe_prop_dim_read(zval *object, zval *member, zend_bool elements, z 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(zend_ce_error, "Cannot create unnamed attribute"); + return &EG(uninitialized_zval); } } @@ -459,7 +459,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(zend_ce_error, "Cannot create unnamed attribute"); return FAILURE; } } else { @@ -498,7 +498,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(zend_ce_error, "Cannot create unnamed attribute"); return FAILURE; } if (attribs && !node && sxe->iter.type == SXE_ITER_ELEMENT) { @@ -571,7 +571,10 @@ static int sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_bool 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(zend_ce_error, "Cannot create duplicate attribute"); + if (new_value) { + zval_ptr_dtor(value); + } return FAILURE; } diff --git a/ext/simplexml/tests/012.phpt b/ext/simplexml/tests/012.phpt index 2fc9bec41e..abbb10b8d3 100644 --- a/ext/simplexml/tests/012.phpt +++ b/ext/simplexml/tests/012.phpt @@ -37,4 +37,7 @@ Warning: main(): Cannot write or create unnamed attribute in %s012.php on line % <?xml version="1.0" encoding="ISO-8859-1"?> <foo attr="new value"/> -Fatal error: main(): Cannot create unnamed attribute in %s012.php on line %d +Fatal error: Uncaught Error: Cannot create unnamed attribute in %s012.php:%d +Stack trace: +#0 {main} + thrown in %s012.php on line %d |