Fix problems arising from incorrect use of various size types
E.g., * `ssize_t` was used where `lit_utf8_size_t` or `jerry_api_size_t` would have been correct, * `lit_utf8_size_t` was used where `ecma_length_t` would have been correct. Note, the patch also includes internal and public API changes: * `ecma_string_to_utf8_string` does not return negative value if output buffer is not large enough to contain the string; the buffer is expected to be large enough. (`ecma_string_get_size` can be used to retrieve the required size.) * `jerry_api_string_to_char_buffer` adapts the same logic (and `jerry_api_get_string_size` can be used to determine the required size of the buffer). Related issue: #942 JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -79,8 +79,8 @@ re_parse_regexp_flags (ecma_string_t *flags_str_p, /**< Input string with flags
|
||||
lit_utf8_size_t flags_str_size = ecma_string_get_size (flags_str_p);
|
||||
MEM_DEFINE_LOCAL_ARRAY (flags_start_p, flags_str_size, lit_utf8_byte_t);
|
||||
|
||||
ssize_t sz = ecma_string_to_utf8_string (flags_str_p, flags_start_p, (ssize_t) flags_str_size);
|
||||
JERRY_ASSERT (sz >= 0);
|
||||
lit_utf8_size_t sz = ecma_string_to_utf8_string (flags_str_p, flags_start_p, flags_str_size);
|
||||
JERRY_ASSERT (sz == flags_str_size);
|
||||
|
||||
lit_utf8_byte_t *flags_str_curr_p = flags_start_p;
|
||||
const lit_utf8_byte_t *flags_str_end_p = flags_start_p + flags_str_size;
|
||||
@@ -349,7 +349,7 @@ re_canonicalize (ecma_char_t ch, /**< character */
|
||||
{
|
||||
/* 2. */
|
||||
ecma_char_t u[LIT_MAXIMUM_OTHER_CASE_LENGTH];
|
||||
lit_utf8_size_t size = lit_char_to_upper_case (ch, u, LIT_MAXIMUM_OTHER_CASE_LENGTH);
|
||||
ecma_length_t size = lit_char_to_upper_case (ch, u, LIT_MAXIMUM_OTHER_CASE_LENGTH);
|
||||
|
||||
/* 3. */
|
||||
if (size == 1)
|
||||
@@ -1281,8 +1281,8 @@ ecma_regexp_exec_helper (ecma_value_t regexp_value, /**< RegExp object */
|
||||
|
||||
re_matcher_ctx_t re_ctx;
|
||||
lit_utf8_byte_t *input_curr_p = NULL;
|
||||
ssize_t sz = ecma_string_to_utf8_string (input_string_p, input_buffer_p, (ssize_t) input_string_size);
|
||||
JERRY_ASSERT (sz >= 0);
|
||||
lit_utf8_size_t sz = ecma_string_to_utf8_string (input_string_p, input_buffer_p, input_string_size);
|
||||
JERRY_ASSERT (sz == input_string_size);
|
||||
|
||||
if (input_string_size == 0u)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user