diff --git a/src/collections_methods.c b/src/collections_methods.c index e9946e1..6c2bc94 100644 --- a/src/collections_methods.c +++ b/src/collections_methods.c @@ -2366,9 +2366,11 @@ PHP_METHOD(Collection, set) zend_array* current = COLLECTION_FETCH_CURRENT(); if (Z_TYPE_P(key) == IS_STRING) { SEPARATE_CURRENT_COLLECTION(current); + Z_TRY_ADDREF_P(value); zend_hash_update(current, Z_STR_P(key), value); } else if (Z_TYPE_P(key) == IS_LONG) { SEPARATE_CURRENT_COLLECTION(current); + Z_TRY_ADDREF_P(value); zend_hash_index_update(current, Z_LVAL_P(key), value); } else { ERR_BAD_KEY_TYPE(); diff --git a/stubs/Collection.php b/stubs/Collection.php index 8c3fc56..0b33e21 100644 --- a/stubs/Collection.php +++ b/stubs/Collection.php @@ -895,4 +895,4 @@ class Collection implements ArrayAccess, Countable * @return Collection */ function values() {} -} \ No newline at end of file +} diff --git a/stubs/Pair.php b/stubs/Pair.php index e67d048..726a173 100644 --- a/stubs/Pair.php +++ b/stubs/Pair.php @@ -26,4 +26,4 @@ class Pair * @param mixed $second */ function __construct($first, $second) {} -} \ No newline at end of file +}