aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-01-30 12:42:15 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-01-30 12:42:15 +0000
commite6034ea2997e9df872c930cd626fc0c71912fc46 (patch)
tree6088fe474b086462ea956e117b8bc3296cfbe9d3
parentc7f51ebeab8ac78e654e83dfb7febb84bf540147 (diff)
Use calloc() to save us the memset() call and terminate conn->host.name
properly, to avoid reading uninited variables when using file:// (valgrind)
-rw-r--r--lib/url.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/url.c b/lib/url.c
index de6d4c2c9..d25f43ebc 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -2182,7 +2182,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
to not have to modify everything at once, we allocate a temporary
connection data struct and fill in for comparison purposes. */
- conn = (struct connectdata *)malloc(sizeof(struct connectdata));
+ conn = (struct connectdata *)calloc(sizeof(struct connectdata), 1);
if(!conn) {
*in_connect = NULL; /* clear the pointer */
return CURLE_OUT_OF_MEMORY;
@@ -2192,9 +2192,6 @@ static CURLcode CreateConnection(struct SessionHandle *data,
any failure */
*in_connect = conn;
- /* we have to init the struct */
- memset(conn, 0, sizeof(struct connectdata));
-
/* and we setup a few fields in case we end up actually using this struct */
conn->data = data; /* remember our daddy */
conn->sock[FIRSTSOCKET] = CURL_SOCKET_BAD; /* no file descriptor */
@@ -2249,6 +2246,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
if(NULL == conn->host.rawalloc)
return CURLE_OUT_OF_MEMORY;
conn->host.name = conn->host.rawalloc;
+ conn->host.name[0] = 0;
/*************************************************************
* Parse the URL.