Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Apr 9, 2022
1 parent e0933d2 commit 677fcde
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,10 @@ struct Slice {
size_t size = 0;
if (IsString(env, from)) {
NAPI_STATUS_THROWS_VOID(napi_get_value_string_utf8(env, from, NULL, 0, &size));
std::string utf8_str(size, '\0');
size_t copied;
NAPI_STATUS_THROWS_VOID(napi_get_value_string_utf8(env, from, &utf8_str[0], utf8_str.length() + 1, &copied));
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));
assert(copied == size);
store_ = utf8_str;
} else if (IsBuffer(env, from)) {
char* data = nullptr;
NAPI_STATUS_THROWS_VOID(napi_get_buffer_info(env, from, reinterpret_cast<void**>(&data), &size));
Expand Down

0 comments on commit 677fcde

Please sign in to comment.