]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: fix two minor memory leaks 667/head
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Jul 2015 01:24:08 +0000 (03:24 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 23 Jul 2015 01:26:01 +0000 (03:26 +0200)
strv_extend() already strdup()s internally, no need to to this twice.
(Also, was missing OOM check...).

Use strv_consume() when we already have a string allocated whose
ownership we want to pass to the strv.

This fixes 50f1e641a93cacfc693b0c3d300bee5df0c8c460.

src/resolve/resolved-dns-rr.c

index 859b3f73399622ef3644005512006746a893db80..9c12205ab8da0681b1adf132aaffc41c89260e04 100644 (file)
@@ -533,7 +533,7 @@ static char *format_types(Bitmap *types) {
 
         BITMAP_FOREACH(type, types, i) {
                 if (dns_type_to_string(type)) {
-                        r = strv_extend(&strv, strdup(dns_type_to_string(type)));
+                        r = strv_extend(&strv, dns_type_to_string(type));
                         if (r < 0)
                                 return NULL;
                 } else {
@@ -543,7 +543,7 @@ static char *format_types(Bitmap *types) {
                         if (r < 0)
                                 return NULL;
 
-                        r = strv_extend(&strv, t);
+                        r = strv_consume(&strv, t);
                         if (r < 0)
                                 return NULL;
                 }