Re: Zend bug? Overloading API in PHP4
| From: | Zeev Suraski | Date: | Fri, 15 Aug 2003 23:19:59 +0000 |
| Subject: | Re: Zend bug? Overloading API in PHP4 | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-4013@lists.php.net to get a copy of this message | ||
At 01:50 16/08/2003, Rasmus Lerdorf wrote:
On Fri, 15 Aug 2003, Rasmus Lerdorf wrote: On Sat, 16 Aug 2003, Zeev Suraski wrote:Nope. Try this instead: zval *tmp; ALLOC_ZVAL(tmp); *tmp = *value; zval_copy_ctor(tmp); INIT_PZVAL(tmp); ZeevYou can't (reliably) connect to zval's that are passed to the setter callback in ZE1, as they're not necessarily reference counted. Ifyou wantto retain them, you have to duplicate them (using zval_copy_ctor()). array(1,2,3) is a temporary value that is destroyed regardless of its reference count.But where do I copy it? As soon as I enter my _set function before I do anything, the passed zval is bogus. Just to verify this, I tried what I think you meant. My setter now looks like this: int _ovl_property_set(zend_property_reference *prop_ref, zval *value) {zend_llist_element *element = prop_ref->elements_list->head; zval overloaded_property = ((zend_overloaded_element *)(element->data))->element; zval *tmp;tmp = value; zval_copy_ctor(tmp); add_property_zval(prop_ref->object, Z_STRVAL(overloaded_property), tmp); return SUCCESS;} No change.