Skip to content

Commit

Permalink
Installed lock protection in _hasListeners due to http://developer.ap…
Browse files Browse the repository at this point in the history
…pcelerator.com/helpdesk/view/47611 , but contextShutdown still has a dangerous unprotected use of listeners exposed. Fixing is nontrivial.
  • Loading branch information
Blain Hamon authored and Blain Hamon committed Oct 6, 2010
1 parent f92707c commit 254df70
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion iphone/Classes/TiProxy.m
Expand Up @@ -239,6 +239,7 @@ -(void)contextShutdown:(id)sender
{
id<TiEvaluator> context = (id<TiEvaluator>)sender;
// remove any listeners that match this context being destroyed that we have registered
//TODO: This listeners needs a lock around it, but not deadlock with the removeEventListener inside.
if (listeners!=nil)
{
for (id type in listeners)
Expand Down Expand Up @@ -461,7 +462,11 @@ -(BOOL)inReproxy

-(BOOL)_hasListeners:(NSString*)type
{
return listeners!=nil && [listeners objectForKey:type]!=nil;
pthread_rwlock_rdlock(&listenerLock);
//If listeners is nil at this point, result is still false.
BOOL result = [listeners objectForKey:type]!=nil;
pthread_rwlock_unlock(&listenerLock);
return result;
}

-(void)_fireEventToListener:(NSString*)type withObject:(id)obj listener:(KrollCallback*)listener thisObject:(TiProxy*)thisObject_
Expand Down

0 comments on commit 254df70

Please sign in to comment.