Check reference count of objects

Throw an error if the object reference count reached the limit.
Related issue: #118

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
László Langó
2016-02-11 15:14:40 +00:00
parent 80811c8332
commit 1dde538224
5 changed files with 20 additions and 4 deletions
+10 -1
View File
@@ -211,7 +211,16 @@ ecma_init_gc_info (ecma_object_t *object_p) /**< object */
void
ecma_ref_object (ecma_object_t *object_p) /**< object */
{
ecma_gc_set_object_refs (object_p, ecma_gc_get_object_refs (object_p) + 1);
uint32_t ref_cnt = ecma_gc_get_object_refs (object_p);
if (ref_cnt < (uint32_t) CONFIG_ECMA_REFERENCE_COUNTER_LIMIT)
{
ecma_gc_set_object_refs (object_p, ref_cnt + 1);
}
else
{
jerry_fatal (ERR_REF_COUNT_LIMIT);
}
} /* ecma_ref_object */
/**