Modify the usage of ecma_string_to_utf8_string()
Parts: * Rename ecma_string_to_utf8_string() to ecma_string_copy_to_utf8_buffer. * Introduce ecma_string_to_utf8_bytes(), which wraps the usual 'function call-assertion' pair, and check strict equality of size of the string and the buffer. JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
This commit is contained in:
@@ -142,7 +142,7 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
|
||||
JMEM_DEFINE_LOCAL_ARRAY (ret_str_buffer, size, lit_utf8_byte_t);
|
||||
lit_utf8_byte_t *ret_str_buffer_p = ret_str_buffer;
|
||||
|
||||
lit_utf8_size_t bytes = ecma_string_to_utf8_string (name_string_p, ret_str_buffer_p, name_size);
|
||||
lit_utf8_size_t bytes = ecma_string_copy_to_utf8_buffer (name_string_p, ret_str_buffer_p, name_size);
|
||||
JERRY_ASSERT (bytes == name_size);
|
||||
ret_str_buffer_p = ret_str_buffer_p + bytes;
|
||||
JERRY_ASSERT (ret_str_buffer_p <= ret_str_buffer + size);
|
||||
@@ -157,7 +157,7 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
|
||||
space_size);
|
||||
JERRY_ASSERT (ret_str_buffer_p <= ret_str_buffer + size);
|
||||
|
||||
bytes = ecma_string_to_utf8_string (msg_string_p, ret_str_buffer_p, msg_size);
|
||||
bytes = ecma_string_copy_to_utf8_buffer (msg_string_p, ret_str_buffer_p, msg_size);
|
||||
JERRY_ASSERT (bytes == msg_size);
|
||||
ret_str_buffer_p = ret_str_buffer_p + bytes;
|
||||
JERRY_ASSERT (ret_str_buffer_p == ret_str_buffer + size);
|
||||
|
||||
@@ -85,8 +85,7 @@ ecma_builtin_global_object_print (ecma_value_t this_arg __attr_unused___, /**< t
|
||||
utf8_str_size,
|
||||
lit_utf8_byte_t);
|
||||
|
||||
lit_utf8_size_t actual_sz = ecma_string_to_utf8_string (str_p, utf8_str_p, utf8_str_size);
|
||||
JERRY_ASSERT (actual_sz == utf8_str_size);
|
||||
ecma_string_to_utf8_bytes (str_p, utf8_str_p, utf8_str_size);
|
||||
|
||||
const lit_utf8_byte_t *utf8_str_curr_p = utf8_str_p;
|
||||
const lit_utf8_byte_t *utf8_str_end_p = utf8_str_p + utf8_str_size;
|
||||
@@ -739,10 +738,7 @@ ecma_builtin_global_object_decode_uri_helper (ecma_value_t uri __attr_unused___,
|
||||
input_size + 1,
|
||||
lit_utf8_byte_t);
|
||||
|
||||
lit_utf8_size_t sz = ecma_string_to_utf8_string (input_string_p,
|
||||
input_start_p,
|
||||
input_size);
|
||||
JERRY_ASSERT (sz == input_size);
|
||||
ecma_string_to_utf8_bytes (input_string_p, input_start_p, input_size);
|
||||
|
||||
input_start_p[input_size] = LIT_BYTE_NULL;
|
||||
|
||||
@@ -1017,10 +1013,7 @@ ecma_builtin_global_object_encode_uri_helper (ecma_value_t uri, /**< uri argumen
|
||||
input_size,
|
||||
lit_utf8_byte_t);
|
||||
|
||||
lit_utf8_size_t sz = ecma_string_to_utf8_string (input_string_p,
|
||||
input_start_p,
|
||||
input_size);
|
||||
JERRY_ASSERT (sz == input_size);
|
||||
ecma_string_to_utf8_bytes (input_string_p, input_start_p, input_size);
|
||||
|
||||
/*
|
||||
* The URI encoding has two major phases: first we validate the input,
|
||||
@@ -1238,10 +1231,7 @@ ecma_builtin_global_object_escape (ecma_value_t this_arg __attr_unused___, /**<
|
||||
input_size,
|
||||
lit_utf8_byte_t);
|
||||
|
||||
lit_utf8_size_t sz = ecma_string_to_utf8_string (input_string_p,
|
||||
input_start_p,
|
||||
input_size);
|
||||
JERRY_ASSERT (sz == input_size);
|
||||
ecma_string_to_utf8_bytes (input_string_p, input_start_p, input_size);
|
||||
|
||||
/*
|
||||
* The escape routine has two major phases: first we compute
|
||||
@@ -1358,8 +1348,7 @@ ecma_builtin_global_object_unescape (ecma_value_t this_arg __attr_unused___, /**
|
||||
|
||||
/* 3. */
|
||||
JMEM_DEFINE_LOCAL_ARRAY (input_start_p, input_size, lit_utf8_byte_t);
|
||||
lit_utf8_size_t sz = ecma_string_to_utf8_string (input_string_p, input_start_p, input_size);
|
||||
JERRY_ASSERT (sz == input_size);
|
||||
ecma_string_to_utf8_bytes (input_string_p, input_start_p, input_size);
|
||||
|
||||
const lit_utf8_byte_t *input_curr_p = input_start_p;
|
||||
const lit_utf8_byte_t *input_end_p = input_start_p + input_size;
|
||||
|
||||
@@ -712,7 +712,7 @@ ecma_builtin_json_parse (ecma_value_t this_arg __attr_unused___, /**< 'this' arg
|
||||
|
||||
JMEM_DEFINE_LOCAL_ARRAY (str_start_p, buffer_size, lit_utf8_byte_t);
|
||||
|
||||
const lit_utf8_size_t sz = ecma_string_to_utf8_string (string_p, str_start_p, buffer_size);
|
||||
const lit_utf8_size_t sz = ecma_string_copy_to_utf8_buffer (string_p, str_start_p, buffer_size);
|
||||
JERRY_ASSERT (sz == string_size);
|
||||
|
||||
str_start_p[string_size] = LIT_BYTE_NULL;
|
||||
|
||||
Reference in New Issue
Block a user