aboutsummaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/url.c b/lib/url.c
index 63c93f1b1..916d2a63c 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -375,19 +375,29 @@ CURLcode Curl_close(struct SessionHandle *data)
/* create a connection cache of a private or multi type */
struct conncache *Curl_mk_connc(int type,
- int amount) /* set -1 to use default */
+ long amount) /* set -1 to use default */
{
/* It is subject for debate how many default connections to have for a multi
connection cache... */
- int default_amount = amount == -1?
- ((type == CONNCACHE_PRIVATE)?5:10):amount;
+
struct conncache *c;
+ long default_amount;
+
+ if (type == CONNCACHE_PRIVATE) {
+ default_amount = (amount < 0) ? 5 : amount;
+ }
+ else {
+ default_amount = (amount < 0) ? 10 : amount;
+ }
c= calloc(sizeof(struct conncache), 1);
if(!c)
return NULL;
- c->connects = calloc(sizeof(struct connectdata *), default_amount);
+ if ((size_t)(default_amount) > ((size_t)-1) / sizeof(struct connectdata *))
+ default_amount = ((size_t)-1) / sizeof(struct connectdata *);
+
+ c->connects = calloc(sizeof(struct connectdata *), (size_t)default_amount);
if(!c->connects) {
free(c);
return NULL;