struct resolv_resolution *resolution;
char *hostname_dn;
int hostname_len, hostname_dn_len;
+ char *hostname_dup = NULL;
+ char *hostname_dn_dup = NULL;
/* Note that the server lock is already held. */
if (!srv->resolvers)
resolv_unlink_resolution(srv->resolv_requester);
+ hostname_dup = strdup(hostname);
+ hostname_dn_dup = strdup(hostname_dn);
+ if (!hostname_dup || !hostname_dn_dup)
+ goto err;
+
free(srv->hostname);
free(srv->hostname_dn);
- srv->hostname = strdup(hostname);
- srv->hostname_dn = strdup(hostname_dn);
+ srv->hostname = hostname_dup;
+ srv->hostname_dn = hostname_dn_dup;
srv->hostname_dn_len = hostname_dn_len;
- if (!srv->hostname || !srv->hostname_dn)
- goto err;
+ hostname_dup = NULL;
+ hostname_dn_dup = NULL;
if (srv->flags & SRV_F_NO_RESOLUTION)
goto end;
err:
if (!resolv_locked)
HA_SPIN_UNLOCK(DNS_LOCK, &srv->resolvers->lock);
+ ha_free(&hostname_dup);
+ ha_free(&hostname_dn_dup);
return -1;
}