readline: fix to not access a property on an undefined value

PR-URL: https://github.com/nodejs/node/pull/43543
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Kohei Ueno authored and Michaël Zasso committed 2022-07-12 07:41:41 +02:00
1 parent 1617a4621e
commit e9574f3009
2 files changed
+24

No files matched your search

+3
View File
@@ -365,6 +365,9 @@ function* emitKeys(stream) {
// This runs in O(n log n).
function commonPrefix(strings) {
if (strings.length === 0) {
return '';
}
if (strings.length === 1) {
return strings[0];
}
@@ -0,0 +1,21 @@
'use strict';
require('../common');
const ArrayStream = require('../common/arraystream');
const repl = require('repl');
const stream = new ArrayStream();
const replServer = repl.start({
input: stream,
output: stream,
terminal: true,
});
// Editor mode
replServer.write('.editor\n');
// Regression test for https://github.com/nodejs/node/issues/43528
replServer.write('a');
replServer.write(null, { name: 'tab' }); // Should not throw
replServer.close();