Browse Source

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>
v4.x
Prince J Wesley 9 years ago
committed by Myles Borins
parent
commit
dca103877f
  1. 2
      lib/_debug_agent.js
  2. 6
      test/parallel/test-debug-agent.js

2
lib/_debug_agent.js

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

6
test/parallel/test-debug-agent.js

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