]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
userdb: shorten code a bit
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 9 May 2021 05:33:20 +0000 (14:33 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 9 May 2021 05:34:23 +0000 (14:34 +0900)
Hopefully fixes CID#1452937.

src/userdb/userwork.c

index 71251ccf1d105f8cf8394053cb036d1fedd05206..418a2892acf194183c174f363a3b7b403565ecdd 100644 (file)
@@ -393,13 +393,10 @@ static int vl_method_get_memberships(Varlink *link, JsonVariant *parameters, Var
                                                             JSON_BUILD_PAIR("groupName", JSON_BUILD_STRING(last_group_name))));
                         if (r < 0)
                                 return r;
-
-                        free(last_user_name);
-                        free(last_group_name);
                 }
 
-                last_user_name = TAKE_PTR(user_name);
-                last_group_name = TAKE_PTR(group_name);
+                free_and_replace(last_user_name, user_name);
+                free_and_replace(last_group_name, group_name);
         }
 
         if (!last_user_name) {