summaryrefslogtreecommitdiff
path: root/ext/simplexml
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-02-20 14:08:43 +0000
committerAntony Dovgal <tony2001@php.net>2007-02-20 14:08:43 +0000
commit180baf01093fc0ed73d9904b85ec93485605c752 (patch)
treeb74718736b5c5d743c1fea9ea96405ac907754f3 /ext/simplexml
parente7544f28b80abb9ba1be696d5c1ec73bf63e311c (diff)
downloadphp-git-180baf01093fc0ed73d9904b85ec93485605c752.tar.gz
MFH: fix leak and errmsg
add test
Diffstat (limited to 'ext/simplexml')
-rw-r--r--ext/simplexml/simplexml.c5
-rw-r--r--ext/simplexml/tests/bug38406.phpt33
2 files changed, 37 insertions, 1 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index a37b858a53..8787e542a1 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -515,7 +515,10 @@ static void sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_boo
}
/* break is missing intentionally */
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "It is not yet possible to assign complex types to %s", attribs ? "attributes" : "properties");
+ if (member == &tmp_zv) {
+ zval_dtor(&tmp_zv);
+ }
+ zend_error(E_WARNING, "It is not yet possible to assign complex types to %s", attribs ? "attributes" : "properties");
return;
}
}
diff --git a/ext/simplexml/tests/bug38406.phpt b/ext/simplexml/tests/bug38406.phpt
new file mode 100644
index 0000000000..f439e33e5e
--- /dev/null
+++ b/ext/simplexml/tests/bug38406.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Bug #38406 (crash when assigning objects to SimpleXML attributes)
+--SKIPIF--
+<?php if (!extension_loaded("simplexml")) print "skip"; ?>
+--FILE--
+<?php
+
+$item = new SimpleXMLElement(b'<something />');
+$item->attribute = b'something';
+var_dump($item->attribute);
+
+$item->otherAttribute = $item->attribute;
+var_dump($item->otherAttribute);
+
+$a = array();
+$item->$a = new stdclass;
+
+echo "Done\n";
+?>
+--EXPECTF--
+object(SimpleXMLElement)#%d (1) {
+ [0]=>
+ string(9) "something"
+}
+object(SimpleXMLElement)#%d (1) {
+ [0]=>
+ string(9) "something"
+}
+
+Notice: Array to string conversion in %s on line %d
+
+Warning: It is not yet possible to assign complex types to properties in %s on line %d
+Done