From 1ce0386a2ffe0d4fdb900b25d40f7caade20678e Mon Sep 17 00:00:00 2001 From: CismonX Date: Wed, 29 Aug 2018 00:55:21 +0800 Subject: [PATCH] Update `distinct()`. --- src/collections_methods.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/collections_methods.c b/src/collections_methods.c index a0c86b3..419d7f8 100644 --- a/src/collections_methods.c +++ b/src/collections_methods.c @@ -898,7 +898,7 @@ PHP_METHOD(Collection, distinct) zend_array* current = COLLECTION_FETCH_CURRENT(); compare_func_t cmp = NULL; equal_check_func_t eql = NULL; - Bucket* ref = (Bucket*)malloc((zend_hash_num_elements(current) + 1) * sizeof(Bucket)); + Bucket* ref = (Bucket*)malloc(zend_hash_num_elements(current) * sizeof(Bucket)); ARRAY_CLONE(distinct, current); uint32_t idx = 0; ZEND_HASH_FOREACH_BUCKET(distinct, Bucket* bucket)