Minor bug solved in node_port.
@@ -316,12 +316,11 @@ napi_value metacall_node_load_from_file(napi_env env, napi_callback_info info)
napi_value tmpValue;
napi_get_element(env, argv[1], i, &tmpValue);
// converting to strings
- char c_strings[256];
+ char c_strings[256] = { 0 };
napi_coerce_to_string(env, tmpValue, &tmpValue);
napi_get_value_string_utf8(env, tmpValue, c_strings, 256, &_result);
- file_name_strings[i] = new char[_result];
- strncpy((char *)file_name_strings[i], c_strings, _result);
-
+ file_name_strings[i] = new char[_result + 1];
+ strncpy((char *)file_name_strings[i], c_strings, _result + 1);
}
if(_result == 0) return NULL;
int met_result = metacall_load_from_file(tagBuf, file_name_strings, sizeof(file_name_strings)/sizeof(file_name_strings[0]), NULL);
@@ -359,6 +358,7 @@ napi_value metacall_node_initialize(napi_env env, napi_value exports)
{
/* TODO: Show error message (when error handling is properly implemented in the core lib) */
napi_throw_error(env, NULL, "MetaCall failed to initialize");
+
return NULL;
}
