Skip to content

Commit 8f39d90

Browse files
rerobikazherczeg
authored andcommitted
Static strings should be reference counted in debug mode (#3219)
This patch helps to find out invalid reference count usage for ecma-strings. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent 7518b7b commit 8f39d90

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

jerry-core/ecma/base/ecma-helpers-string.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,17 @@ ecma_ref_ecma_string (ecma_string_t *string_p) /**< string descriptor */
822822
{
823823
JERRY_ASSERT (string_p != NULL);
824824

825-
if (ECMA_IS_DIRECT_STRING (string_p) || ECMA_STRING_IS_STATIC (string_p))
825+
if (ECMA_IS_DIRECT_STRING (string_p))
826+
{
827+
return;
828+
}
829+
830+
#ifdef JERRY_NDEBUG
831+
if (ECMA_STRING_IS_STATIC (string_p))
826832
{
827833
return;
828834
}
835+
#endif /* JERRY_NDEBUG */
829836

830837
JERRY_ASSERT (string_p->refs_and_container >= ECMA_STRING_REF_ONE);
831838

@@ -849,10 +856,17 @@ ecma_deref_ecma_string (ecma_string_t *string_p) /**< ecma-string */
849856
{
850857
JERRY_ASSERT (string_p != NULL);
851858

852-
if (ECMA_IS_DIRECT_STRING (string_p) || ECMA_STRING_IS_STATIC (string_p))
859+
if (ECMA_IS_DIRECT_STRING (string_p))
860+
{
861+
return;
862+
}
863+
864+
#ifdef JERRY_NDEBUG
865+
if (ECMA_STRING_IS_STATIC (string_p))
853866
{
854867
return;
855868
}
869+
#endif /* JERRY_NDEBUG */
856870

857871
JERRY_ASSERT (string_p->refs_and_container >= ECMA_STRING_REF_ONE);
858872

0 commit comments

Comments
 (0)