File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
test/js-native-api/test_string Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ static napi_status create_external_one_byte(napi_env env,
126
126
const size_t length_bytes = (actual_length + 1 ) * sizeof (* string_copy );
127
127
string_copy = malloc (length_bytes );
128
128
memcpy (string_copy , string , length_bytes );
129
- string_copy [length ] = 0 ;
129
+ string_copy [length_bytes - 1 ] = 0 ;
130
130
131
131
status = create_api (env , string_copy , length , result );
132
132
if (status != napi_ok ) {
@@ -183,7 +183,7 @@ static napi_status create_external_utf16(napi_env env,
183
183
const size_t length_bytes = (actual_length + 1 ) * sizeof (* string_copy );
184
184
string_copy = malloc (length_bytes );
185
185
memcpy (string_copy , string , length_bytes );
186
- string_copy [length ] = 0 ;
186
+ string_copy [length_bytes - 1 ] = 0 ;
187
187
188
188
status =
189
189
node_api_create_external_string_utf16 (env , string_copy , length , result );
You can’t perform that action at this time.
0 commit comments