Skip to content

Commit 68d7253

Browse files
committed
Add a limit assert.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
1 parent a5143e1 commit 68d7253

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

jerry-core/ecma/base/ecma-globals.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,8 @@ typedef enum
686686
ECMA_STRING_CONTAINER_UINT32_IN_DESC, /**< actual data is UInt32-represeneted Number
687687
stored locally in the string's descriptor */
688688
ECMA_STRING_CONTAINER_MAGIC_STRING, /**< the ecma-string is equal to one of ECMA magic strings */
689-
ECMA_STRING_CONTAINER_MAGIC_STRING_EX /**< the ecma-string is equal to one of external magic strings */
689+
ECMA_STRING_CONTAINER_MAGIC_STRING_EX, /**< the ecma-string is equal to one of external magic strings */
690+
ECMA_STRING_CONTAINER__COUNT /** count of container types */
690691
} ecma_string_container_t;
691692

692693
/**

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ JERRY_STATIC_ASSERT ((int32_t) ECMA_STRING_MAX_CONCATENATION_LENGTH ==
5252
JERRY_STATIC_ASSERT (ECMA_STRING_CONTAINER_MASK + 1 == ECMA_STRING_REF_ONE,
5353
ecma_string_ref_counter_should_start_after_the_container_field);
5454

55+
/**
56+
* The ecma string container types must be lower than the container mask.
57+
*/
58+
JERRY_STATIC_ASSERT (ECMA_STRING_CONTAINER_MASK + 1 >= ECMA_STRING_CONTAINER__COUNT,
59+
ecma_string_container_types_must_be_lower_than_the_container_mask);
60+
5561
/**
5662
* The ecma string ref and container fields should fill the 16 bit field.
5763
*/
@@ -506,10 +512,14 @@ ecma_deref_ecma_string (ecma_string_t *string_p) /**< ecma-string */
506512
case ECMA_STRING_CONTAINER_MAGIC_STRING_EX:
507513
{
508514
/* only the string descriptor itself should be freed */
515+
break;
516+
}
517+
case ECMA_STRING_CONTAINER__COUNT:
518+
{
519+
JERRY_UNREACHABLE ();
509520
}
510521
}
511522

512-
513523
ecma_dealloc_string (string_p);
514524
} /* ecma_deref_ecma_string */
515525

@@ -565,6 +575,10 @@ ecma_string_to_number (const ecma_string_t *str_p) /**< ecma-string */
565575

566576
return num;
567577
}
578+
case ECMA_STRING_CONTAINER__COUNT:
579+
{
580+
JERRY_UNREACHABLE ();
581+
}
568582
}
569583

570584
JERRY_UNREACHABLE ();

0 commit comments

Comments
 (0)