mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix buffer overflow in example for jerry_string_to_char_buffer() API function (#3010)
We need one more byte allocated for the trailing '\0'. JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
This commit is contained in:
parent
a834288096
commit
ff2e75ed2e
@ -2790,7 +2790,7 @@ main (void)
|
||||
|
||||
// Read the string into a byte buffer.
|
||||
jerry_size_t string_size = jerry_get_string_size (value);
|
||||
jerry_char_t *string_buffer_p = (jerry_char_t *) malloc (sizeof (jerry_char_t) * string_size);
|
||||
jerry_char_t *string_buffer_p = (jerry_char_t *) malloc (sizeof (jerry_char_t) * (string_size + 1));
|
||||
|
||||
jerry_size_t copied_bytes = jerry_string_to_char_buffer (value, string_buffer_p, string_size);
|
||||
string_buffer_p[copied_bytes] = '\0';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user