Skip to content

Commit 9b4dd7e

Browse files
committed
fix: fix buffer to value safe conversion
1 parent b8df7ec commit 9b4dd7e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/incoming_msg.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,22 @@ Napi::Value IncomingMsg::IntoBuffer(const Napi::Env& env) {
4242
Napi::MemoryManagement::AdjustExternalMemory(
4343
env, static_cast<int64_t>(length));
4444

45-
auto release = [](const Napi::Env& env, uint8_t*, Reference* ref) {
45+
const auto release = [](const Napi::Env& env, uint8_t*, Reference* ref) {
4646
const auto length = static_cast<int64_t>(zmq_msg_size(ref->get()));
4747
Napi::MemoryManagement::AdjustExternalMemory(env, -length);
4848
delete ref;
4949
};
5050

51-
return Napi::Buffer<uint8_t>::New(env, data, length, release, ref);
51+
return Napi::Buffer<uint8_t>::New(env, data, length, release, ref)
52+
.As<Napi::Value>();
5253
}
5354
}
5455

5556
if (length > 0) {
56-
return Napi::Buffer<uint8_t>::Copy(env, data, length);
57+
return Napi::Buffer<uint8_t>::Copy(env, data, length).As<Napi::Value>();
5758
}
5859

59-
return Napi::Buffer<uint8_t>::New(env, 0);
60+
return Napi::Buffer<uint8_t>::New(env, 0).As<Napi::Value>();
6061
}
6162

6263
IncomingMsg::Reference::Reference() {

0 commit comments

Comments
 (0)