From: Dmitry Stogov Date: Fri, 28 Feb 2014 07:21:15 +0000 (+0400) Subject: Fixed SEPARATE_ZVAL() to support objects and resources X-Git-Tag: POST_PHPNG_MERGE~412^2~492^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5b5367ddbb1da19ac0b88a5736cec46cab9b0bc2;p=php Fixed SEPARATE_ZVAL() to support objects and resources --- diff --git a/Zend/zend.h b/Zend/zend.h index b62a022e42..1ac7914c75 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -680,15 +680,20 @@ END_EXTERN_C() Z_UNSET_ISREF_P(z); \ } while (0) -// TODO: support objects and resources??? -#define SEPARATE_ZVAL(zv) do { \ - if (Z_REFCOUNTED_P(zv)) { \ - if (Z_REFCOUNT_P(zv) > 1) { \ - Z_DELREF_P(zv); \ - zval_copy_ctor(zv); \ - Z_SET_REFCOUNT_P(zv, 1); \ - } \ - } \ +// TODO: support objects and resources in more optimal way ??? +#define SEPARATE_ZVAL(zv) do { \ + if (Z_REFCOUNTED_P(zv)) { \ + if (Z_REFCOUNT_P(zv) > 1) { \ + if (Z_TYPE_P(zv) == IS_OBJECT || \ + Z_TYPE_P(zv) == IS_RESOURCE) { \ + Z_ADDREF_P(zv); \ + } else { \ + Z_DELREF_P(zv); \ + zval_copy_ctor(zv); \ + Z_SET_REFCOUNT_P(zv, 1); \ + } \ + } \ + } \ } while (0) #define SEPARATE_ZVAL_IF_NOT_REF(zv) \