Fix crash when removing a listener

// FREEBIE
This commit is contained in:
lilia 2016-01-14 15:33:03 -08:00
parent f7c4fd2fed
commit 75b2c9c5de
2 changed files with 12 additions and 8 deletions

View file

@ -36242,10 +36242,12 @@ window.textsecure.utils = function() {
this.listeners = {}; this.listeners = {};
} }
var listeners = this.listeners[eventName]; var listeners = this.listeners[eventName];
for (var i=0; i < listeners.length; ++ i) { if (typeof listeners === 'object') {
if (listeners[i] === callback) { for (var i=0; i < listeners.length; ++ i) {
listeners.splice(i, 1); if (listeners[i] === callback) {
return; listeners.splice(i, 1);
return;
}
} }
} }
this.listeners[eventName] = listeners; this.listeners[eventName] = listeners;

View file

@ -59,10 +59,12 @@
this.listeners = {}; this.listeners = {};
} }
var listeners = this.listeners[eventName]; var listeners = this.listeners[eventName];
for (var i=0; i < listeners.length; ++ i) { if (typeof listeners === 'object') {
if (listeners[i] === callback) { for (var i=0; i < listeners.length; ++ i) {
listeners.splice(i, 1); if (listeners[i] === callback) {
return; listeners.splice(i, 1);
return;
}
} }
} }
this.listeners[eventName] = listeners; this.listeners[eventName] = listeners;