Skip to content

Commit 4dd2749

Browse files
committed
lib: replace eval with vm.runInThisContext
Refs: #18212 (review)
1 parent 60e612d commit 4dd2749

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
'internal/deps/v8/tools/splaytree',
@@ -31,9 +34,9 @@ if (process.platform === 'darwin') {
3134
tickArguments.push('--windows');
3235
}
3336
tickArguments.push.apply(tickArguments, process.argv.slice(1));
34-
script = `(function() {
37+
script = `(function(require) {
3538
arguments = ${JSON.stringify(tickArguments)};
3639
function write (s) { process.stdout.write(s) }
3740
${script}
38-
})()`;
39-
eval(script);
41+
})`;
42+
vm.runInThisContext(script)(require);

0 commit comments

Comments
 (0)