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,
126126 const size_t length_bytes = (actual_length + 1 ) * sizeof (* string_copy );
127127 string_copy = malloc (length_bytes );
128128 memcpy (string_copy , string , length_bytes );
129- string_copy [length ] = 0 ;
129+ string_copy [length_bytes - 1 ] = 0 ;
130130
131131 status = create_api (env , string_copy , length , result );
132132 if (status != napi_ok ) {
@@ -183,7 +183,7 @@ static napi_status create_external_utf16(napi_env env,
183183 const size_t length_bytes = (actual_length + 1 ) * sizeof (* string_copy );
184184 string_copy = malloc (length_bytes );
185185 memcpy (string_copy , string , length_bytes );
186- string_copy [length ] = 0 ;
186+ string_copy [length_bytes - 1 ] = 0 ;
187187
188188 status =
189189 node_api_create_external_string_utf16 (env , string_copy , length , result );
You can’t perform that action at this time.
0 commit comments