From eafccdb3150115e94f16a3a21ea989aeb65a0210 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 19 Dec 2012 19:52:11 +0100 Subject: bundles connection caching: some out of memory handling fixes --- lib/bundles.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/bundles.c') 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, + * Copyright (C) 2012, Daniel Stenberg, , 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); } -- cgit v1.2.3