diff options
author | Yang Tse <yangsita@gmail.com> | 2012-12-19 19:52:11 +0100 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2012-12-19 19:53:17 +0100 |
commit | eafccdb3150115e94f16a3a21ea989aeb65a0210 (patch) | |
tree | 2385a66043f2202abd44be144aa26cfb3dc7b320 /lib/bundles.c | |
parent | b7a1eccce8daeb69c9ffedfabc89c353c8be4969 (diff) | |
download | curl-eafccdb3150115e94f16a3a21ea989aeb65a0210.tar.gz |
bundles connection caching: some out of memory handling fixes
Diffstat (limited to 'lib/bundles.c')
-rw-r--r-- | lib/bundles.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/bundles.c b/lib/bundles.c index 046e3bb3b..f09ee2a35 100644 --- a/lib/bundles.c +++ b/lib/bundles.c @@ -6,6 +6,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2012, Linus Nielsen Feltzing, <linus@haxx.se> + * Copyright (C) 2012, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -48,6 +49,7 @@ CURLcode Curl_bundle_create(struct SessionHandle *data, struct connectbundle **cb_ptr) { (void)data; + DEBUGASSERT(*cb_ptr == NULL); *cb_ptr = malloc(sizeof(struct connectbundle)); if(!*cb_ptr) return CURLE_OUT_OF_MEMORY; @@ -56,15 +58,22 @@ CURLcode Curl_bundle_create(struct SessionHandle *data, (*cb_ptr)->server_supports_pipelining = FALSE; (*cb_ptr)->conn_list = Curl_llist_alloc((curl_llist_dtor) conn_llist_dtor); - if(!(*cb_ptr)->conn_list) + if(!(*cb_ptr)->conn_list) { + Curl_safefree(*cb_ptr); return CURLE_OUT_OF_MEMORY; + } return CURLE_OK; } void Curl_bundle_destroy(struct connectbundle *cb_ptr) { - if(cb_ptr->conn_list) + if(!cb_ptr) + return; + + if(cb_ptr->conn_list) { Curl_llist_destroy(cb_ptr->conn_list, NULL); + cb_ptr->conn_list = NULL; + } Curl_safefree(cb_ptr); } |