aboutsummaryrefslogtreecommitdiff
path: root/ares/ares_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'ares/ares_init.c')
-rw-r--r--ares/ares_init.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ares/ares_init.c b/ares/ares_init.c
index ac626e9ce..bc7e97ad6 100644
--- a/ares/ares_init.c
+++ b/ares/ares_init.c
@@ -975,6 +975,9 @@ static int init_by_defaults(ares_channel channel)
{
char *hostname = NULL;
int rc = ARES_SUCCESS;
+#ifdef HAVE_GETHOSTNAME
+ char *dot;
+#endif
if (channel->flags == -1)
channel->flags = 0;
@@ -1044,15 +1047,15 @@ static int init_by_defaults(ares_channel channel)
} while(0);
- if (strchr(hostname, '.')) {
+ dot = strchr(hostname, '.');
+ if (dot) {
/* a dot was found */
-
channel->domains = malloc(sizeof(char *));
if (!channel->domains) {
rc = ARES_ENOMEM;
goto error;
}
- channel->domains[0] = strdup(strchr(hostname, '.') + 1);
+ channel->domains[0] = strdup(dot + 1);
if (!channel->domains[0]) {
rc = ARES_ENOMEM;
goto error;