diff options
author | Daniel Stenberg <daniel@haxx.se> | 2004-05-13 15:18:29 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2004-05-13 15:18:29 +0000 |
commit | b6ee33c6e11decca2842a356c6d68f2bd28d00a0 (patch) | |
tree | 77258e7086619d046892e489e0ebabb1378d47a1 | |
parent | 1c69b15c7c8e019b96bb640d33d6256069a3cfd4 (diff) |
check that memory allocation functions truly return good data or bail out
-rw-r--r-- | lib/share.c | 44 |
1 files changed, 22 insertions, 22 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<<type); - switch( type ) - { - case CURL_LOCK_DATA_DNS: - if (!share->hostcache) { - share->hostcache = Curl_mk_dnscache(); - } - 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: - break; - - case CURL_LOCK_DATA_CONNECT: - break; - - default: - return CURLSHE_BAD_OPTION; + 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_SSL_SESSION: /* not supported (yet) */ + case CURL_LOCK_DATA_CONNECT: /* not supported (yet) */ + + default: + return CURLSHE_BAD_OPTION; } break; |