Skip to content

Commit

Permalink
lib: replace eval with vm.runInThisContext
Browse files Browse the repository at this point in the history
PR-URL: #18623
Refs: #18212 (review)
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
MylesBorins authored and rvagg committed Aug 16, 2018
1 parent f0f44f6 commit 2702fd7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/internal/v8_prof_processor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* eslint-disable strict */
'use strict';

const vm = require('vm');

const scriptFiles = [
'internal/v8_prof_polyfill',
'v8/tools/splaytree',
Expand Down Expand Up @@ -30,9 +33,9 @@ if (process.platform === 'darwin') {
tickArguments.push('--windows');
}
tickArguments.push.apply(tickArguments, process.argv.slice(1));
script = `(function() {
script = `(function(require) {
arguments = ${JSON.stringify(tickArguments)};
function write (s) { process.stdout.write(s) }
${script}
})()`;
eval(script);
})`;
vm.runInThisContext(script)(require);

0 comments on commit 2702fd7

Please sign in to comment.