Skip to content

Commit

Permalink
src: call IsSingleExecutable() before FindSingleExecutableCode()
Browse files Browse the repository at this point in the history
This also serves as a workaround for nodejs/postject#70.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
  • Loading branch information
RaisinTen committed Feb 11, 2023
1 parent 94aad51 commit 274e0df
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,23 +312,25 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) {
}

#ifndef DISABLE_SINGLE_EXECUTABLE_APPLICATION
size_t single_executable_application_size = 0;
const char* single_executable_application_code =
FindSingleExecutableCode(&single_executable_application_size);
if (single_executable_application_code != nullptr) {
Local<Value> buffer =
Buffer::New(
env->isolate(),
const_cast<char*>(single_executable_application_code),
single_executable_application_size,
[](char* data, void* hint) {},
nullptr)
.ToLocalChecked();
env->process_object()
->SetPrivate(
env->context(), env->single_executable_application_code(), buffer)
.Check();
return StartExecution(env, "internal/main/single_executable_application");
if (IsSingleExecutable()) {
size_t single_executable_application_size = 0;
const char* single_executable_application_code =
FindSingleExecutableCode(&single_executable_application_size);
if (single_executable_application_code != nullptr) {
Local<Value> buffer =
Buffer::New(
env->isolate(),
const_cast<char*>(single_executable_application_code),
single_executable_application_size,
[](char* data, void* hint) {},
nullptr)
.ToLocalChecked();
env->process_object()
->SetPrivate(
env->context(), env->single_executable_application_code(), buffer)
.Check();
return StartExecution(env, "internal/main/single_executable_application");
}
}
#endif

Expand Down

0 comments on commit 274e0df

Please sign in to comment.