]> granicus.if.org Git - php/commitdiff
Fixed array_unshift()
authorDmitry Stogov <dmitry@zend.com>
Fri, 21 Feb 2014 13:38:12 +0000 (17:38 +0400)
committerDmitry Stogov <dmitry@zend.com>
Fri, 21 Feb 2014 13:38:12 +0000 (17:38 +0400)
ext/standard/array.c

index 502d15ea3ac1f5dbefe09541adea8bedc62a6fe1..f16cc409697bc38b3bef7beadd481fd7fed7419d 100644 (file)
@@ -1861,7 +1861,7 @@ PHPAPI HashTable* php_splice(HashTable *in_hash, int offset, int length, zval *l
                /* ..for each one, create a new zval, copy entry into it and copy it into the output hash */
                for (i = 0; i < list_count; i++) {
                        entry = &list[i];
-                       Z_ADDREF_P(entry);
+                       if (IS_REFCOUNTED(Z_TYPE_P(entry))) Z_ADDREF_P(entry);
                        zend_hash_next_index_insert(out_hash, entry);
                }
        }
@@ -1871,7 +1871,7 @@ PHPAPI HashTable* php_splice(HashTable *in_hash, int offset, int length, zval *l
                p = in_hash->arData + idx;
                if (Z_TYPE(p->val) == IS_UNDEF) continue;
                entry = &p->val;
-               Z_ADDREF_P(entry);
+               if (IS_REFCOUNTED(Z_TYPE_P(entry))) Z_ADDREF_P(entry);
                if (p->key == NULL) {
                        zend_hash_next_index_insert(out_hash, entry);
                } else {