Skip to content

Commit 3d64d2b

Browse files
cjihrigtargos
authored andcommitted
readline: check for null input in question()
question() checks for objects passed as the recently added options argument. This commit improves that logic to also check for null. PR-URL: #37089 Reviewed-By: Zijian Liu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent fe9f4fd commit 3d64d2b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/readline.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ Interface.prototype.prompt = function(preserveCursor) {
364364

365365
Interface.prototype.question = function(query, options, cb) {
366366
cb = typeof options === 'function' ? options : cb;
367-
options = typeof options === 'object' ? options : {};
367+
options = typeof options === 'object' && options !== null ? options : {};
368368

369369
if (options.signal) {
370370
options.signal.addEventListener('abort', () => {
@@ -385,7 +385,7 @@ Interface.prototype.question = function(query, options, cb) {
385385
};
386386

387387
Interface.prototype.question[promisify.custom] = function(query, options) {
388-
options = typeof options === 'object' ? options : {};
388+
options = typeof options === 'object' && options !== null ? options : {};
389389

390390
return new Promise((resolve, reject) => {
391391
this.question(query, options, resolve);

0 commit comments

Comments
 (0)