Skip to content

Commit ce8b468

Browse files
authored
Merge pull request #218 from nielsdos/fix-216
Fix #216: Memory leak in Ds\Set and Ds\Map when using Ds\Hashable as a key
2 parents 4a62484 + b139fba commit ce8b468

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ds/ds_htable.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,11 @@ static uint32_t get_object_hash(zval *obj)
280280
case IS_DOUBLE:
281281
return get_double_hash(&hash);
282282

283-
case IS_STRING:
284-
return get_string_zval_hash(&hash);
283+
case IS_STRING: {
284+
uint32_t ret = get_string_zval_hash(&hash);
285+
zval_ptr_dtor_str(&hash);
286+
return ret;
287+
}
285288

286289
case IS_TRUE:
287290
return 1;
@@ -292,6 +295,7 @@ static uint32_t get_object_hash(zval *obj)
292295

293296
default:
294297
OBJ_HASH_MUST_BE_SCALAR(&hash);
298+
zval_ptr_dtor(&hash);
295299
return 0;
296300
}
297301
}

0 commit comments

Comments
 (0)