Skip to content

Commit b02030d

Browse files
cjihrigLxxyx
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 <lxxyxzj@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
1 parent 1b222f9 commit b02030d

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
@@ -372,7 +372,7 @@ Interface.prototype.prompt = function(preserveCursor) {
372372

373373
Interface.prototype.question = function(query, options, cb) {
374374
cb = typeof options === 'function' ? options : cb;
375-
options = typeof options === 'object' ? options : {};
375+
options = typeof options === 'object' && options !== null ? options : {};
376376

377377
if (options.signal) {
378378
options.signal.addEventListener('abort', () => {
@@ -393,7 +393,7 @@ Interface.prototype.question = function(query, options, cb) {
393393
};
394394

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

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

0 commit comments

Comments
 (0)