diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-06-19 13:56:39 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-06-19 13:56:39 +0000 |
| commit | 1a755d0da2075ba0cccaaacd616f31eec697b08a (patch) | |
| tree | 70cd029435745974836c3db86bce01e9b22eb814 /uri.c | |
| parent | term: fix regression after merging #599 (diff) | |
uri: hostname_is_localhost(): don’t crash if hostname == NULL
Diffstat (limited to 'uri.c')
| -rw-r--r-- | uri.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -270,7 +270,8 @@ hostname_is_localhost(const char *hostname) if (gethostname(this_host, sizeof(this_host)) < 0) this_host[0] = '\0'; - return (strcmp(hostname, "") == 0 || - strcmp(hostname, "localhost") == 0 || - strcmp(hostname, this_host) == 0); + return (hostname != NULL && ( + strcmp(hostname, "") == 0 || + strcmp(hostname, "localhost") == 0 || + strcmp(hostname, this_host) == 0)); } |
