Skip to content

Commit ae96dde

Browse files
committed
Safely register commands
1 parent 7435ccf commit ae96dde

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

v8-debug.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,24 @@ V8Debug.prototype._unwrapDebugCommandProcessor = function() {
169169
V8Debug.prototype.register =
170170
V8Debug.prototype.registerCommand = function(name, func) {
171171
var proto = this._DebugCommandProcessor;
172+
if (!proto) return;
173+
172174
proto.extendedProcessDebugJSONRequestHandles_[name] = func;
173175
};
174176

175177
V8Debug.prototype.unregister =
176178
V8Debug.prototype.unregisterCommand = function(name, func) {
177179
var proto = this._DebugCommandProcessor;
180+
if (!proto) return;
181+
178182
delete proto.extendedProcessDebugJSONRequestHandles_[name];
179183
};
180184

181185
V8Debug.prototype.registerAsync =
182186
V8Debug.prototype.registerAsyncCommand = function(name, func) {
183187
var proto = this._DebugCommandProcessor;
188+
if (!proto) return;
189+
184190
proto.extendedProcessDebugJSONRequestAsyncHandles_[name] = func;
185191
};
186192

0 commit comments

Comments
 (0)