diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0f2f52c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,83 @@ +{ + "files.associations": { + "__bit_reference": "cpp", + "__bits": "cpp", + "__config": "cpp", + "__debug": "cpp", + "__errc": "cpp", + "__functional_base": "cpp", + "__hash_table": "cpp", + "__locale": "cpp", + "__mutex_base": "cpp", + "__node_handle": "cpp", + "__nullptr": "cpp", + "__split_buffer": "cpp", + "__string": "cpp", + "__threading_support": "cpp", + "__tree": "cpp", + "__tuple": "cpp", + "algorithm": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "complex": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "exception": "cpp", + "functional": "cpp", + "initializer_list": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "iterator": "cpp", + "limits": "cpp", + "locale": "cpp", + "map": "cpp", + "memory": "cpp", + "mutex": "cpp", + "new": "cpp", + "numbers": "cpp", + "numeric": "cpp", + "optional": "cpp", + "ostream": "cpp", + "queue": "cpp", + "random": "cpp", + "ratio": "cpp", + "semaphore": "cpp", + "set": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "thread": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "unordered_map": "cpp", + "utility": "cpp", + "vector": "cpp", + "*.tcc": "cpp", + "memory_resource": "cpp", + "stop_token": "cpp", + "__memory": "cpp" + } +} \ No newline at end of file diff --git a/binding.cc b/binding.cc index bce1d3f..e7fae4a 100644 --- a/binding.cc +++ b/binding.cc @@ -354,7 +354,9 @@ struct Slice { NAPI_STATUS_THROWS_VOID(napi_get_value_string_utf8(env, from, NULL, 0, &size)); store_.resize(size, '\0'); size_t copied = 0; - NAPI_STATUS_THROWS_VOID(napi_get_value_string_utf8(env, from, &store_[0], store_.length() + 1, &copied)); + const auto status = napi_get_value_string_utf8(env, from, &store_[0], store_.length() + 1, &copied); + store_.resize(copied); + NAPI_STATUS_THROWS_VOID(status); assert(copied == size); } else if (IsBuffer(env, from)) { char* data = nullptr;