From: Zbigniew Jędrzejewski-Szmek Date: Fri, 5 Jun 2020 12:03:30 +0000 (+0200) Subject: resolved: fix memleak on duplicate host lines in /etc/hosts X-Git-Tag: v246-rc1~105^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab9dd0b9975c69953cb73d6c04f1a6af0bb9d5fa;p=thirdparty%2Fsystemd.git resolved: fix memleak on duplicate host lines in /etc/hosts --- diff --git a/src/resolve/resolved-etc-hosts.c b/src/resolve/resolved-etc-hosts.c index a2c84c17a4d..6a7f7499572 100644 --- a/src/resolve/resolved-etc-hosts.c +++ b/src/resolve/resolved-etc-hosts.c @@ -120,11 +120,10 @@ static int parse_line(EtcHosts *hosts, unsigned nr, const char *line) { /* Optimize the case where we don't need to store any addresses, by storing * only the name in a dedicated Set instead of the hashmap */ - r = set_ensure_put(&hosts->no_address, &dns_name_hash_ops, name); + r = set_ensure_consume(&hosts->no_address, &dns_name_hash_ops, TAKE_PTR(name)); if (r < 0) return r; - TAKE_PTR(name); continue; }