Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-24364] (6_0_X) iOS: Fix HTTP-leak on Kroll-Thread #8919

Merged
merged 2 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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