Skip to content

Commit 06a1b82

Browse files
monneratbagder
authored andcommitted
cookie: get_top_domain() sets zero length for null domains
This silents a compilation warning with gcc -O3.
1 parent a75f127 commit 06a1b82

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/cookie.c

+9-10
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,17 @@ static bool pathmatch(const char *cookie_path, const char *request_uri)
245245
*/
246246
static const char *get_top_domain(const char * const domain, size_t *outlen)
247247
{
248-
size_t len;
248+
size_t len = 0;
249249
const char *first = NULL, *last;
250250

251-
if(!domain)
252-
return NULL;
253-
254-
len = strlen(domain);
255-
last = memrchr(domain, '.', len);
256-
if(last) {
257-
first = memrchr(domain, '.', (last - domain));
258-
if(first)
259-
len -= (++first - domain);
251+
if(domain) {
252+
len = strlen(domain);
253+
last = memrchr(domain, '.', len);
254+
if(last) {
255+
first = memrchr(domain, '.', (last - domain));
256+
if(first)
257+
len -= (++first - domain);
258+
}
260259
}
261260

262261
if(outlen)

0 commit comments

Comments
 (0)