1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-05 00:55:04 -05:00

cookie: get_top_domain() sets zero length for null domains

This silents a compilation warning with gcc -O3.
This commit is contained in:
Patrick Monnerat 2020-01-28 10:23:41 +01:00 committed by Daniel Stenberg
parent a75f12768d
commit 06a1b82140
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -245,18 +245,17 @@ pathmatched:
*/ */
static const char *get_top_domain(const char * const domain, size_t *outlen) 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; const char *first = NULL, *last;
if(!domain) if(domain) {
return NULL; len = strlen(domain);
last = memrchr(domain, '.', len);
len = strlen(domain); if(last) {
last = memrchr(domain, '.', len); first = memrchr(domain, '.', (last - domain));
if(last) { if(first)
first = memrchr(domain, '.', (last - domain)); len -= (++first - domain);
if(first) }
len -= (++first - domain);
} }
if(outlen) if(outlen)