Skip to content

Commit b1de93a

Browse files
author
Ruben Ayrapetyan
committed
Fix incorrect assertion in lit_utf8_iterator_seek.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
1 parent 4f44071 commit b1de93a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

jerry-core/lit/lit-strings.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,13 @@ lit_utf8_iterator_seek (lit_utf8_iterator_t *iter_p, /**< utf-8 string iterator
296296
{
297297
JERRY_ASSERT (iter_pos.offset <= iter_p->buf_size);
298298
#ifndef JERRY_NDEBUG
299-
lit_utf8_byte_t byte = *(iter_p->buf_p + iter_pos.offset);
300-
JERRY_ASSERT ((byte & LIT_UTF8_EXTRA_BYTE_MASK) != LIT_UTF8_EXTRA_BYTE_MARKER);
301-
JERRY_ASSERT (!iter_pos.is_non_bmp_middle || ((byte & LIT_UTF8_4_BYTE_MASK) == LIT_UTF8_4_BYTE_MARKER));
302-
#endif
299+
if (iter_pos.offset < iter_p->buf_size)
300+
{
301+
lit_utf8_byte_t byte = *(iter_p->buf_p + iter_pos.offset);
302+
JERRY_ASSERT ((byte & LIT_UTF8_EXTRA_BYTE_MASK) != LIT_UTF8_EXTRA_BYTE_MARKER);
303+
JERRY_ASSERT (!iter_pos.is_non_bmp_middle || ((byte & LIT_UTF8_4_BYTE_MASK) == LIT_UTF8_4_BYTE_MARKER));
304+
}
305+
#endif /* !JERRY_NDEBUG */
303306

304307
iter_p->buf_pos = iter_pos;
305308
} /* lit_utf8_iterator_seek */

0 commit comments

Comments
 (0)