nwrap: Small code shift in nwrap_ed_inventarize_add_to_existing()
authorRobin Hack <hack.robin@gmail.com>
Mon, 16 Nov 2015 22:38:51 +0000 (23:38 +0100)
committerMichael Adam <obnox@samba.org>
Mon, 11 Jan 2016 11:25:31 +0000 (12:25 +0100)
Allocate memory only when necessary.

Signed-off-by: Robin Hack <hack.robin@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/nss_wrapper/nss_wrapper.c

index a8cbc222ac79e4d4f330f933289cf031263644b0..d204ea60a8f31de6b6ee3908819efc88387d115f 100644 (file)
@@ -2610,21 +2610,20 @@ static bool nwrap_ed_inventarize_add_to_existing(struct nwrap_entdata *const ed,
                return false;
        }
 
-       el_new = nwrap_entlist_init(ed);
-       if (el_new == NULL) {
-               return false;
-       }
 
        for (cursor = el; cursor->next != NULL; cursor = cursor->next)
        {
                if (cursor->ed == ed) {
-                       free(el_new);
                        return false;
                }
        }
 
        if (cursor->ed == ed) {
-               free(el_new);
+               return false;
+       }
+
+       el_new = nwrap_entlist_init(ed);
+       if (el_new == NULL) {
                return false;
        }