aboutsummaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2007-02-01 01:42:13 +0000
committerYang Tse <yangsita@gmail.com>2007-02-01 01:42:13 +0000
commit54db98c220255737456b1311cb9534c9e95215c6 (patch)
treea9ee1b3e102a5d9c099068a220412e5989f520d8 /lib/url.c
parent5565f45f5e5213df213336f99d19a471c1ac2632 (diff)
compiler warning fix
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;