summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Monnerat <patrick@monnerat.net>2020-01-28 10:23:41 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-03-08 17:30:55 +0100
commit06a1b821404c176fde883a826a0db712695dd964 (patch)
treeb5a1a0d339797d1578d13d4b618402351985ee87
parenta75f12768dee349e5671022c2bbea5428e6cca19 (diff)
downloadcurl-06a1b821404c176fde883a826a0db712695dd964.tar.gz
cookie: get_top_domain() sets zero length for null domains
This silents a compilation warning with gcc -O3.
-rw-r--r--lib/cookie.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/cookie.c b/lib/cookie.c
index 69bc04260..68054e1c4 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -245,18 +245,17 @@ pathmatched:
*/
static const char *get_top_domain(const char * const domain, size_t *outlen)
{
- size_t len;
+ size_t len = 0;
const char *first = NULL, *last;
- if(!domain)
- return NULL;
-
- len = strlen(domain);
- last = memrchr(domain, '.', len);
- if(last) {
- first = memrchr(domain, '.', (last - domain));
- if(first)
- len -= (++first - domain);
+ if(domain) {
+ len = strlen(domain);
+ last = memrchr(domain, '.', len);
+ if(last) {
+ first = memrchr(domain, '.', (last - domain));
+ if(first)
+ len -= (++first - domain);
+ }
}
if(outlen)