mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: crash in utilityProcess when generating code from strings (#38040)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: deepak1556 <hop2deep@gmail.com>
This commit is contained in:
@@ -360,5 +360,19 @@ describe('utilityProcess module', () => {
|
||||
await emittedOnce(child, 'exit');
|
||||
expect(log).to.equal('hello\n');
|
||||
});
|
||||
|
||||
it('does not crash when running eval', async () => {
|
||||
const child = utilityProcess.fork('./eval.js', [], {
|
||||
cwd: fixturesPath,
|
||||
stdio: 'ignore'
|
||||
});
|
||||
await emittedOnce(child, 'spawn');
|
||||
const [data] = await emittedOnce(child, 'message');
|
||||
expect(data).to.equal(42);
|
||||
// Cleanup.
|
||||
const exit = emittedOnce(child, 'exit');
|
||||
expect(child.kill()).to.be.true();
|
||||
await exit;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
6
spec/fixtures/api/utility-process/eval.js
vendored
Normal file
6
spec/fixtures/api/utility-process/eval.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
const vm = require('node:vm');
|
||||
|
||||
const contextObject = { result: 0 };
|
||||
vm.createContext(contextObject);
|
||||
vm.runInContext('eval(\'result = 42\')', contextObject);
|
||||
process.parentPort.postMessage(contextObject.result);
|
||||
Reference in New Issue
Block a user