Skip to content

Commit 47dfe29

Browse files
committed
lib: replace eval with vm.runInThisContext
PR-URL: #18623 Refs: #18212 (review) Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent d1ff8fa commit 47dfe29

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/internal/v8_prof_processor.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
/* eslint-disable strict */
1+
'use strict';
2+
3+
const vm = require('vm');
4+
25
const scriptFiles = [
36
'internal/v8_prof_polyfill',
47
'v8/tools/splaytree',
@@ -30,9 +33,9 @@ if (process.platform === 'darwin') {
3033
tickArguments.push('--windows');
3134
}
3235
tickArguments.push.apply(tickArguments, process.argv.slice(1));
33-
script = `(function() {
36+
script = `(function(require) {
3437
arguments = ${JSON.stringify(tickArguments)};
3538
function write (s) { process.stdout.write(s) }
3639
${script}
37-
})()`;
38-
eval(script);
40+
})`;
41+
vm.runInThisContext(script)(require);

0 commit comments

Comments
 (0)