From 3d64d2b5efd084400044e7cfdc99a68d477a3b1f Mon Sep 17 00:00:00 2001 From: cjihrig Date: Tue, 26 Jan 2021 20:47:47 -0500 Subject: [PATCH] readline: check for null input in question() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit question() checks for objects passed as the recently added options argument. This commit improves that logic to also check for null. PR-URL: https://github.com/nodejs/node/pull/37089 Reviewed-By: Zijian Liu Reviewed-By: James M Snell Reviewed-By: Juan José Arboleda Reviewed-By: Darshan Sen --- lib/readline.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/readline.js b/lib/readline.js index b95bb877d23..1793cb21264 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -364,7 +364,7 @@ Interface.prototype.prompt = function(preserveCursor) { Interface.prototype.question = function(query, options, cb) { cb = typeof options === 'function' ? options : cb; - options = typeof options === 'object' ? options : {}; + options = typeof options === 'object' && options !== null ? options : {}; if (options.signal) { options.signal.addEventListener('abort', () => { @@ -385,7 +385,7 @@ Interface.prototype.question = function(query, options, cb) { }; Interface.prototype.question[promisify.custom] = function(query, options) { - options = typeof options === 'object' ? options : {}; + options = typeof options === 'object' && options !== null ? options : {}; return new Promise((resolve, reject) => { this.question(query, options, resolve);