Skip to content

Commit

Permalink
Merge pull request #8919 from hansemannn/TIMOB-24364-6_0_X
Browse files Browse the repository at this point in the history
[TIMOB-24364] (6_0_X) iOS: Fix HTTP-leak on Kroll-Thread
  • Loading branch information
htbryant94 committed Apr 12, 2017
2 parents ac32488 + ae221cf commit f803f0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
20 changes: 15 additions & 5 deletions iphone/Classes/KrollObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,11 @@ -(void)invokeCallbackForKey:(NSString *)key withObject:(NSDictionary *)eventData
initWithTarget:self selector:_cmd object:key object:eventData object:thisObject];
[context enqueue:safeInvoke];
[safeInvoke release];

if (block != nil) {
block(nil);
}

return;
}
#else
Expand All @@ -1195,7 +1200,9 @@ -(void)invokeCallbackForKey:(NSString *)key withObject:(NSDictionary *)eventData
jsProxyHash = TiValueToObject(jsContext, jsProxyHash, &exception);
if ((jsProxyHash == NULL) || (TiValueGetType(jsContext,jsProxyHash) != kTITypeObject))
{
if (block != nil) block(nil);
if (block != nil) {
block(nil);
}
return;
}

Expand All @@ -1205,7 +1212,9 @@ -(void)invokeCallbackForKey:(NSString *)key withObject:(NSDictionary *)eventData

if ((jsCallback == NULL) || (TiValueGetType(jsContext,jsCallback) != kTITypeObject))
{
if (block != nil) block(nil);
if (block != nil) {
block(nil);
}
return;
}

Expand All @@ -1216,9 +1225,10 @@ -(void)invokeCallbackForKey:(NSString *)key withObject:(NSDictionary *)eventData
id excm = [KrollObject toID:context value:exception];
[[TiExceptionHandler defaultExceptionHandler] reportScriptError:[TiUtils scriptErrorValue:excm]];
}
if (block != nil) {
block(TiValueToId(context, result));
};

if (block != nil) {
block(TiValueToId(context, result));
};
#ifndef TI_USE_KROLL_THREAD
};
TiThreadPerformOnMainThread(mainBlock, NO);
Expand Down
6 changes: 3 additions & 3 deletions iphone/Classes/TiNetworkHTTPClientProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,13 @@ -(void)request:(APSHTTPRequest *)request onLoad:(APSHTTPResponse *)response
if (hasOnerror && (responseCode >= 400) && (responseCode <= 599)) {
NSMutableDictionary * event = [TiUtils dictionaryWithCode:responseCode message:@"HTTP error"];
[event setObject:@"error" forKey:@"type"];
[self fireCallback:@"onerror" withArg:event withSource:self withHandler:^(id result){
[self fireCallback:@"onerror" withArg:event withSource:self withHandler:^(id result) {
[self forgetSelf];
}];
} else if(hasOnload) {
NSMutableDictionary * event = [TiUtils dictionaryWithCode:0 message:nil];
[event setObject:@"load" forKey:@"type"];
[self fireCallback:@"onload" withArg:event withSource:self withHandler:^(id result){
[self fireCallback:@"onload" withArg:event withSource:self withHandler:^(id result) {
[self forgetSelf];
}];
} else {
Expand Down Expand Up @@ -547,4 +547,4 @@ -(NSDictionary*)responseHeaders

@end

#endif
#endif

0 comments on commit f803f0c

Please sign in to comment.