@@ -726,7 +726,7 @@ ecma_append_chars_to_string (ecma_string_t *string1_p, /**< base ecma-string */
726
726
lit_utf8_size_t cesu8_string1_size ;
727
727
lit_utf8_size_t cesu8_string1_length ;
728
728
uint8_t flags = ECMA_STRING_FLAG_IS_ASCII ;
729
- lit_utf8_byte_t uint32_to_string_buffer [ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 ];
729
+ lit_utf8_byte_t uint32_to_string_buffer [ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED ];
730
730
731
731
const lit_utf8_byte_t * cesu8_string1_p =
732
732
ecma_string_get_chars (string1_p , & cesu8_string1_size , & cesu8_string1_length , uint32_to_string_buffer , & flags );
@@ -831,7 +831,7 @@ ecma_concat_ecma_strings (ecma_string_t *string1_p, /**< first ecma-string */
831
831
832
832
lit_utf8_size_t cesu8_string2_size ;
833
833
lit_utf8_size_t cesu8_string2_length ;
834
- lit_utf8_byte_t uint32_to_string_buffer [ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 ];
834
+ lit_utf8_byte_t uint32_to_string_buffer [ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED ];
835
835
uint8_t flags = ECMA_STRING_FLAG_IS_ASCII ;
836
836
837
837
const lit_utf8_byte_t * cesu8_string2_p =
@@ -1081,8 +1081,9 @@ ecma_uint32_to_buffer (uint32_t num, /**< number */
1081
1081
lit_utf8_byte_t * buffer_p /**< destination buffer */ ,
1082
1082
lit_utf8_size_t buffer_size /**< buffer size */ )
1083
1083
{
1084
- lit_utf8_byte_t digits [ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 ];
1085
- lit_utf8_size_t digit_count = ecma_uint32_to_utf8_string (num , digits , ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 );
1084
+ lit_utf8_byte_t digits [ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED ];
1085
+ lit_utf8_size_t digit_count =
1086
+ ecma_uint32_to_utf8_string (num , digits , ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED );
1086
1087
1087
1088
digit_count = JERRY_MIN (buffer_size , digit_count );
1088
1089
memcpy (buffer_p , digits , digit_count );
@@ -1192,7 +1193,7 @@ ecma_string_to_cesu8_bytes (const ecma_string_t *string_desc_p, /**< ecma-string
1192
1193
*
1193
1194
* @return size in bytes
1194
1195
*/
1195
- static inline lit_utf8_size_t JERRY_ATTR_ALWAYS_INLINE
1196
+ extern inline lit_utf8_size_t JERRY_ATTR_ALWAYS_INLINE
1196
1197
ecma_string_get_uint32_size (const uint32_t uint32_number ) /**< number in the string-descriptor */
1197
1198
{
1198
1199
uint32_t prev_number = 1 ;
@@ -1292,11 +1293,11 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
1292
1293
}
1293
1294
else
1294
1295
{
1295
- result_p = (const lit_utf8_byte_t * ) jmem_heap_alloc_block (size );
1296
+ result_p = (const lit_utf8_byte_t * ) jmem_heap_alloc_block (size + 1 );
1296
1297
* flags_p |= ECMA_STRING_FLAG_MUST_BE_FREED ;
1297
1298
}
1298
1299
1299
- length = ecma_uint32_to_utf8_string (uint32_number , (lit_utf8_byte_t * ) result_p , size );
1300
+ length = ecma_uint32_to_utf8_string (uint32_number , (lit_utf8_byte_t * ) result_p , size + 1 );
1300
1301
1301
1302
JERRY_ASSERT (length == size );
1302
1303
* flags_p |= ECMA_STRING_FLAG_IS_UINT32 ;
@@ -1343,11 +1344,11 @@ ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
1343
1344
}
1344
1345
else
1345
1346
{
1346
- result_p = (const lit_utf8_byte_t * ) jmem_heap_alloc_block (size );
1347
+ result_p = (const lit_utf8_byte_t * ) jmem_heap_alloc_block (size + 1 );
1347
1348
* flags_p |= ECMA_STRING_FLAG_MUST_BE_FREED ;
1348
1349
}
1349
1350
1350
- length = ecma_uint32_to_utf8_string (string_p -> u .uint32_number , (lit_utf8_byte_t * ) result_p , size );
1351
+ length = ecma_uint32_to_utf8_string (string_p -> u .uint32_number , (lit_utf8_byte_t * ) result_p , size + 1 );
1351
1352
1352
1353
JERRY_ASSERT (length == size );
1353
1354
* flags_p |= ECMA_STRING_FLAG_IS_UINT32 | ECMA_STRING_FLAG_REHASH_NEEDED ;
@@ -1716,8 +1717,8 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
1716
1717
const lit_utf8_byte_t * utf8_string1_p , * utf8_string2_p ;
1717
1718
lit_utf8_size_t utf8_string1_size , utf8_string2_size ;
1718
1719
1719
- lit_utf8_byte_t uint32_to_string_buffer1 [ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 ];
1720
- lit_utf8_byte_t uint32_to_string_buffer2 [ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 ];
1720
+ lit_utf8_byte_t uint32_to_string_buffer1 [ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED ];
1721
+ lit_utf8_byte_t uint32_to_string_buffer2 [ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED ];
1721
1722
1722
1723
if (ECMA_IS_DIRECT_STRING (string1_p ))
1723
1724
{
@@ -1729,7 +1730,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
1729
1730
{
1730
1731
utf8_string1_size = ecma_uint32_to_utf8_string ((uint32_t ) ECMA_GET_DIRECT_STRING_VALUE (string1_p ),
1731
1732
uint32_to_string_buffer1 ,
1732
- ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 );
1733
+ ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED );
1733
1734
utf8_string1_p = uint32_to_string_buffer1 ;
1734
1735
}
1735
1736
}
@@ -1745,7 +1746,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
1745
1746
{
1746
1747
utf8_string1_size = ecma_uint32_to_utf8_string (string1_p -> u .uint32_number ,
1747
1748
uint32_to_string_buffer1 ,
1748
- ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 );
1749
+ ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED );
1749
1750
utf8_string1_p = uint32_to_string_buffer1 ;
1750
1751
}
1751
1752
}
@@ -1760,7 +1761,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
1760
1761
{
1761
1762
utf8_string2_size = ecma_uint32_to_utf8_string ((uint32_t ) ECMA_GET_DIRECT_STRING_VALUE (string2_p ),
1762
1763
uint32_to_string_buffer2 ,
1763
- ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 );
1764
+ ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED );
1764
1765
utf8_string2_p = uint32_to_string_buffer2 ;
1765
1766
}
1766
1767
}
@@ -1776,7 +1777,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma-
1776
1777
{
1777
1778
utf8_string2_size = ecma_uint32_to_utf8_string (string2_p -> u .uint32_number ,
1778
1779
uint32_to_string_buffer2 ,
1779
- ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 );
1780
+ ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED );
1780
1781
utf8_string2_p = uint32_to_string_buffer2 ;
1781
1782
}
1782
1783
}
@@ -2061,7 +2062,7 @@ ecma_string_get_char_at_pos (const ecma_string_t *string_p, /**< ecma-string */
2061
2062
{
2062
2063
JERRY_ASSERT (index < ecma_string_get_length (string_p ));
2063
2064
2064
- lit_utf8_byte_t uint32_to_string_buffer [ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 ];
2065
+ lit_utf8_byte_t uint32_to_string_buffer [ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED ];
2065
2066
2066
2067
if (ECMA_IS_DIRECT_STRING (string_p ))
2067
2068
{
@@ -2086,7 +2087,9 @@ ecma_string_get_char_at_pos (const ecma_string_t *string_p, /**< ecma-string */
2086
2087
JERRY_ASSERT (ECMA_GET_DIRECT_STRING_TYPE (string_p ) == ECMA_DIRECT_STRING_UINT );
2087
2088
uint32_t uint32_number = (uint32_t ) ECMA_GET_DIRECT_STRING_VALUE (string_p );
2088
2089
2089
- ecma_uint32_to_utf8_string (uint32_number , uint32_to_string_buffer , ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 );
2090
+ ecma_uint32_to_utf8_string (uint32_number ,
2091
+ uint32_to_string_buffer ,
2092
+ ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED );
2090
2093
2091
2094
return (ecma_char_t ) uint32_to_string_buffer [index ];
2092
2095
}
@@ -2132,7 +2135,7 @@ ecma_string_get_char_at_pos (const ecma_string_t *string_p, /**< ecma-string */
2132
2135
{
2133
2136
ecma_uint32_to_utf8_string (string_p -> u .uint32_number ,
2134
2137
uint32_to_string_buffer ,
2135
- ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32 );
2138
+ ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32_WITH_ZERO_TERMINATED );
2136
2139
2137
2140
return (ecma_char_t ) uint32_to_string_buffer [index ];
2138
2141
}
0 commit comments