Skip to content

Commit

Permalink
sea: fix memory leak detected by asan
Browse files Browse the repository at this point in the history
Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: #47309
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
RaisinTen authored and danielleadams committed Jul 6, 2023
1 parent b851fdb commit 0621bdb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
20 changes: 7 additions & 13 deletions src/node_sea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,13 @@ std::tuple<int, char**> FixupArgsForSEA(int argc, char** argv) {
// Repeats argv[0] at position 1 on argv as a replacement for the missing
// entry point file path.
if (IsSingleExecutable()) {
char** new_argv = new char*[argc + 2];
int new_argc = 0;
new_argv[new_argc++] = argv[0];
new_argv[new_argc++] = argv[0];

for (int i = 1; i < argc; ++i) {
new_argv[new_argc++] = argv[i];
}

new_argv[new_argc] = nullptr;

argc = new_argc;
argv = new_argv;
static std::vector<char*> new_argv;
new_argv.reserve(argc + 2);
new_argv.emplace_back(argv[0]);
new_argv.insert(new_argv.end(), argv, argv + argc);
new_argv.emplace_back(nullptr);
argc = new_argv.size() - 1;
argv = new_argv.data();
}

return {argc, argv};
Expand Down
3 changes: 0 additions & 3 deletions test/parallel/test-single-executable-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ if (!process.config.variables.single_executable_application)
if (!['darwin', 'win32', 'linux'].includes(process.platform))
common.skip(`Unsupported platform ${process.platform}.`);

if (process.platform === 'linux' && process.config.variables.asan)
common.skip('Running the resultant binary fails with `Segmentation fault (core dumped)`.');

if (process.platform === 'linux' && process.config.variables.is_debug === 1)
common.skip('Running the resultant binary fails with `Couldn\'t read target executable"`.');

Expand Down

0 comments on commit 0621bdb

Please sign in to comment.