]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/useradd.c: set_defaults(): Fix order of clean-ups
authorAlejandro Colomar <alx@kernel.org>
Fri, 17 May 2024 12:05:31 +0000 (14:05 +0200)
committerAlejandro Colomar <alx@kernel.org>
Fri, 17 May 2024 23:15:10 +0000 (01:15 +0200)
Resources should be freed in the inverse order of the allocation.
This refactor prepares for the following commits, which fix some leaks.

Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/useradd.c

index 88d8ab7f140a49cc58f5a00d463df75501202973..56a7455948837515aeeb76ae964f8d0dcc1ffb82 100644 (file)
@@ -745,10 +745,9 @@ static int set_defaults (void)
                 def_create_mail_spool, def_log_init));
        ret = 0;
     setdef_err:
-       free(new_file);
-       if (prefix[0]) {
+       if (prefix[0])
                free(default_file);
-       }
+       free(new_file);
 
        return ret;
 }