]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: fix memleak on duplicate host lines in /etc/hosts
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 5 Jun 2020 12:03:30 +0000 (14:03 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 24 Jun 2020 08:38:15 +0000 (10:38 +0200)
src/resolve/resolved-etc-hosts.c

index a2c84c17a4d53f13dd64f7a47cd8512e6f7666a3..6a7f7499572cfc9592e64ab7233468960e9654ee 100644 (file)
@@ -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;
                 }