mirror of
https://github.com/nodejs/node.git
synced 2025-05-20 02:55:51 +00:00

When `throw undefined` or `throw null` is executed, the REPL crashes. This change does a check for `null|undefined` before accessing an error's properties to prevent crashing. Fixes: https://github.com/nodejs/node/issues/16545 Fixes: https://github.com/nodejs/node/issues/16607 PR-URL: https://github.com/nodejs/node/pull/16574 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Lance Ball <lball@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
19 lines
443 B
JavaScript
19 lines
443 B
JavaScript
'use strict';
|
|
require('../common');
|
|
|
|
// This test ensures that the repl does not
|
|
// crash or emit error when throwing `null|undefined`
|
|
// ie `throw null` or `throw undefined`
|
|
|
|
const assert = require('assert');
|
|
const repl = require('repl');
|
|
|
|
const r = repl.start();
|
|
|
|
assert.doesNotThrow(() => {
|
|
r.write('throw null\n');
|
|
r.write('throw undefined\n');
|
|
}, TypeError, 'repl crashes/throw error on `throw null|undefined`');
|
|
|
|
r.write('.exit\n');
|