]> khamidou — GitHub mirrors - electron.git/commitdiff
Guard against undefined, fix #2995
authorCheng Zhao <zcbenz@gmail.com>
Tue, 6 Oct 2015 14:25:55 +0000 (22:25 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 6 Oct 2015 14:25:55 +0000 (22:25 +0800)
In theory this should never happen, seems like some object is garbage
collected after the JavaScript context has been destroyed.

atom/browser/lib/objects-registry.coffee

index ccfe2dbe0ad21c58f9053eb63569f81eeba5fe20..667adbc24e9e333b861fc716d4dbb6488ccc7131 100644 (file)
@@ -34,6 +34,7 @@ class ObjectsRegistry extends EventEmitter
     @dereference id, 1
     # Also reduce the count in owner.
     pointer = @owners[webContentsId]
+    return unless pointer?
     --pointer[id]
     delete pointer[id] if pointer[id] is 0
 
@@ -57,6 +58,7 @@ class ObjectsRegistry extends EventEmitter
   # Private: Dereference the object from store.
   dereference: (id, count) ->
     pointer = @storage[id]
+    return unless pointer?
     pointer.count -= count
     if pointer.count is 0
       v8Util.deleteHiddenValue pointer.object, 'atomId'