From b6ee33c6e11decca2842a356c6d68f2bd28d00a0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 13 May 2004 15:18:29 +0000 Subject: [PATCH] check that memory allocation functions truly return good data or bail out --- lib/share.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/share.c b/lib/share.c index ced7e188d..d1292c4ae 100644 --- a/lib/share.c +++ b/lib/share.c @@ -68,28 +68,28 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...) /* this is a type this share will share */ type = va_arg(param, int); share->specifier |= (1<hostcache) { - share->hostcache = Curl_mk_dnscache(); - } - break; + switch( type ) { + case CURL_LOCK_DATA_DNS: + if (!share->hostcache) { + share->hostcache = Curl_mk_dnscache(); + if(!share->hostcache) + return CURLSHE_NOMEM; + } + break; + + case CURL_LOCK_DATA_COOKIE: + if (!share->cookies) { + share->cookies = Curl_cookie_init(NULL, NULL, NULL, TRUE ); + if(!share->cookies) + return CURLSHE_NOMEM; + } + break; - case CURL_LOCK_DATA_COOKIE: - if (!share->cookies) { - share->cookies = Curl_cookie_init(NULL, NULL, NULL, TRUE ); - } - break; + case CURL_LOCK_DATA_SSL_SESSION: /* not supported (yet) */ + case CURL_LOCK_DATA_CONNECT: /* not supported (yet) */ - case CURL_LOCK_DATA_SSL_SESSION: - break; - - case CURL_LOCK_DATA_CONNECT: - break; - - default: - return CURLSHE_BAD_OPTION; + default: + return CURLSHE_BAD_OPTION; } break;