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 = {};
}
var listeners = this.listeners[eventName];
for (var i=0; i < listeners.length; ++ i) {
if (listeners[i] === callback) {
listeners.splice(i, 1);
return;
if (typeof listeners === 'object') {
for (var i=0; i < listeners.length; ++ i) {
if (listeners[i] === callback) {
listeners.splice(i, 1);
return;
}
}
}
this.listeners[eventName] = listeners;

View file

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