From b139fbaba20f9de8b7d248103eb0f0fabc9af1d4 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Fri, 17 Oct 2025 21:05:21 +0200 Subject: [PATCH] Fix #216: Memory leak in Ds\Set and Ds\Map when using Ds\Hashable as a key The return value zval should be destroyed. --- src/ds/ds_htable.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ds/ds_htable.c b/src/ds/ds_htable.c index 48622e7..1079701 100644 --- a/src/ds/ds_htable.c +++ b/src/ds/ds_htable.c @@ -280,8 +280,11 @@ static uint32_t get_object_hash(zval *obj) case IS_DOUBLE: return get_double_hash(&hash); - case IS_STRING: - return get_string_zval_hash(&hash); + case IS_STRING: { + uint32_t ret = get_string_zval_hash(&hash); + zval_ptr_dtor_str(&hash); + return ret; + } case IS_TRUE: return 1; @@ -292,6 +295,7 @@ static uint32_t get_object_hash(zval *obj) default: OBJ_HASH_MUST_BE_SCALAR(&hash); + zval_ptr_dtor(&hash); return 0; } }