diff options
author | Rob Richards <rrichards@php.net> | 2004-02-15 18:57:10 +0000 |
---|---|---|
committer | Rob Richards <rrichards@php.net> | 2004-02-15 18:57:10 +0000 |
commit | 2a32e4328a592564090bd8367897ef0d2dbe75cc (patch) | |
tree | 5fefe6d4bb374117251ab4236ab658657aa07fe3 /ext/dom/attr.c | |
parent | 595d6a2d8406436beb6e8191e746bebb9926bab9 (diff) | |
download | php-git-2a32e4328a592564090bd8367897ef0d2dbe75cc.tar.gz |
switch to zend_parse_method_parameters for consistancy
insure object parameters are correct class types
convert zvals to correct type if needed for property writes
fix a few segfaults found while testing
Diffstat (limited to 'ext/dom/attr.c')
-rw-r--r-- | ext/dom/attr.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/ext/dom/attr.c b/ext/dom/attr.c index c5bf81897a..057d0d52e9 100644 --- a/ext/dom/attr.c +++ b/ext/dom/attr.c @@ -136,18 +136,18 @@ int dom_attr_value_read(dom_object *obj, zval **retval TSRMLS_DC) if ((content = xmlNodeGetContent((xmlNodePtr) attrp)) != NULL) { ZVAL_STRING(*retval, content, 1); + xmlFree(content); } else { ZVAL_EMPTY_STRING(*retval); } - xmlFree(content); - return SUCCESS; } int dom_attr_value_write(dom_object *obj, zval *newval TSRMLS_DC) { + zval value_copy; xmlAttrPtr attrp; attrp = (xmlAttrPtr) dom_object_get_node(obj); @@ -155,8 +155,22 @@ int dom_attr_value_write(dom_object *obj, zval *newval TSRMLS_DC) if (attrp->children) { node_list_unlink(attrp->children TSRMLS_CC); } + + if (newval->type != IS_STRING) { + if(newval->refcount > 1) { + value_copy = *newval; + zval_copy_ctor(&value_copy); + newval = &value_copy; + } + convert_to_string(newval); + } + xmlNodeSetContentLen((xmlNodePtr) attrp, Z_STRVAL_P(newval), Z_STRLEN_P(newval) + 1); + if (newval == &value_copy) { + zval_dtor(newval); + } + return SUCCESS; } @@ -223,7 +237,11 @@ PHP_FUNCTION(dom_attr_is_id) xmlAttrPtr attrp; xmlNodePtr nodep; - DOM_GET_THIS_OBJ(attrp, id, xmlAttrPtr, intern); + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, dom_attr_class_entry) == FAILURE) { + return; + } + + DOM_GET_OBJ(attrp, id, xmlAttrPtr, intern); nodep = attrp->parent; |