We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dc8bca5 commit 77bfbd4Copy full SHA for 77bfbd4
1 file changed
src/node_sea.cc
@@ -191,12 +191,19 @@ void GetCodeCache(const FunctionCallbackInfo<Value>& args) {
191
192
SeaResource sea_resource = FindSingleExecutableResource();
193
194
- Local<Object> buf =
195
- Buffer::Copy(
196
- env,
197
- reinterpret_cast<const char*>(sea_resource.code_cache.data()),
198
- sea_resource.code_cache.length())
199
- .ToLocalChecked();
+ Local<Object> buf;
+ if (!Buffer::New(
+ env,
+ const_cast<char*>(sea_resource.code_cache.data()),
+ sea_resource.code_cache.length(),
+ [](char* /* data */, void* /* hint */) {
200
+ // We don't free the code cache data string because it is not owned
201
+ // by us.
202
+ },
203
+ nullptr)
204
+ .ToLocal(&buf)) {
205
+ return;
206
+ }
207
208
args.GetReturnValue().Set(buf);
209
}
0 commit comments