From: Patrick Monnerat Date: Tue, 28 Jan 2020 09:23:41 +0000 (+0100) Subject: cookie: get_top_domain() sets zero length for null domains X-Git-Tag: curl-7_69_1~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06a1b821404c176fde883a826a0db712695dd964;p=thirdparty%2Fcurl.git cookie: get_top_domain() sets zero length for null domains This silents a compilation warning with gcc -O3. --- diff --git a/lib/cookie.c b/lib/cookie.c index 69bc04260a..68054e1c4c 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)