debugger: assert test before accessing this.binding

PR-URL: https://github.com/nodejs/node/pull/5145
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Prince J Wesley 2016-02-09 03:33:19 +05:30 committed by James M Snell
parent 4e46931406
commit 826844e27e
2 changed files with 7 additions and 1 deletions

View File

@ -48,6 +48,7 @@ function Agent() {
this.first = true;
this.binding = process._debugAPI;
assert(this.binding, 'Debugger agent running without bindings!');
var self = this;
this.binding.onmessage = function(msg) {
@ -57,7 +58,6 @@ function Agent() {
};
this.clients = [];
assert(this.binding, 'Debugger agent running without bindings!');
}
util.inherits(Agent, net.Server);

View File

@ -0,0 +1,6 @@
'use strict';
require('../common');
const assert = require('assert');
assert.throws(() => { require('_debug_agent').start(); },
assert.AssertionError);