]> Chaos Git - corbenik/ctrulib.git/commitdiff
Reverting previous commit, fixing more resource leaks
authorplutoo <plutoo@inbox.com>
Mon, 15 Dec 2014 00:43:18 +0000 (01:43 +0100)
committerplutoo <plutoo@inbox.com>
Mon, 15 Dec 2014 00:43:18 +0000 (01:43 +0100)
libctru/source/services/httpc.c

index 9d9ab386f348ca98575a44a889d568c8fb01abdd..a9f1eb9582ab33ff9c622cced80756927cbb4130 100644 (file)
@@ -36,10 +36,14 @@ Result httpcOpenContext(httpcContext *context, char* url, u32 use_defaultproxy)
        if(ret!=0)return ret;
 
        ret = srvGetServiceHandle(&context->servhandle, "http:C");
-       if(ret!=0)return ret;
+       if(ret!=0) {
+               HTTPC_CloseContext(__httpc_servhandle, context->httphandle);
+               return ret;
+        }
 
        ret = HTTPC_InitializeConnectionSession(context->servhandle, context->httphandle);
        if(ret!=0) {
+               HTTPC_CloseContext(__httpc_servhandle, context->httphandle);
                svcCloseHandle(context->servhandle);
                return ret;
         }
@@ -48,6 +52,7 @@ Result httpcOpenContext(httpcContext *context, char* url, u32 use_defaultproxy)
 
        ret = HTTPC_SetProxyDefault(context->servhandle, context->httphandle);
        if(ret!=0) {
+               HTTPC_CloseContext(__httpc_servhandle, context->httphandle);
                svcCloseHandle(context->servhandle);
                return ret;
         }
@@ -59,7 +64,7 @@ Result httpcCloseContext(httpcContext *context)
 {
        Result ret=0;
 
-       ret = HTTPC_CloseContext(__httpc_servhandle, context->httphandle);
+       ret = HTTPC_CloseContext(context->servhandle, context->httphandle);
        svcCloseHandle(context->servhandle);
 
        return ret;