diff --git a/lib/repl.js b/lib/repl.js index 11ee6f58216..0f93bfdc40a 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -217,7 +217,7 @@ function REPLServer(prompt, self.setPrompt(prompt !== undefined ? prompt : '> '); - this.commands = {}; + this.commands = Object.create(null); defineDefaultCommands(this); // figure out which "writer" function to use diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 94d6bca283c..65affa9b948 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -194,6 +194,10 @@ function error_test() { // the error message { client: client_unix, send: '.invalid_repl_command', expect: 'Invalid REPL keyword\n' + prompt_unix }, + // this makes sure that we don't crash when we use an inherited property as + // a REPL command + { client: client_unix, send: '.toString', + expect: 'Invalid REPL keyword\n' + prompt_unix }, ]); }