]> Chaos Git - corbenik/ctrulib.git/commitdiff
Fixed handle leak in httpc
authorplutoo <plutoo@inbox.com>
Mon, 15 Dec 2014 00:33:37 +0000 (01:33 +0100)
committerplutoo <plutoo@inbox.com>
Mon, 15 Dec 2014 00:33:37 +0000 (01:33 +0100)
libctru/source/services/httpc.c

index e299b8d6b77347abf3aa853a807ba17e0027faf1..a9095c31a913908e454e4f5648a91bca14566563 100644 (file)
@@ -39,12 +39,18 @@ Result httpcOpenContext(httpcContext *context, char* url, u32 use_defaultproxy)
        if(ret!=0)return ret;
 
        ret = HTTPC_InitializeConnectionSession(context->servhandle, context->httphandle);
-       if(ret!=0)return ret;
+       if(ret!=0) {
+               svcCloseHandle(context->servhandle);
+               return ret;
+        }
 
        if(use_defaultproxy==0)return 0;
 
        ret = HTTPC_SetProxyDefault(context->servhandle, context->httphandle);
-       if(ret!=0)return ret;
+       if(ret!=0) {
+               svcCloseHandle(context->servhandle);
+               return ret;
+        }
 
        return 0;
 }
@@ -54,7 +60,6 @@ Result httpcCloseContext(httpcContext *context)
        Result ret=0;
 
        ret = HTTPC_CloseContext(context->servhandle, context->httphandle);
-
        svcCloseHandle(context->servhandle);
 
        return ret;