]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: libsmb: Cleanup - move talloc frame out of inner scope.
authorJeremy Allison <jra@samba.org>
Wed, 15 Jul 2020 20:28:33 +0000 (13:28 -0700)
committerVolker Lendecke <vl@samba.org>
Thu, 16 Jul 2020 06:52:36 +0000 (06:52 +0000)
Make it available thoughout the function. Prepare to use
talloc for namecache_key().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/libsmb/namecache.c

index 832daea1e01765fdf4e07173b9484115229d3bba..76d411e87d11724d1c4bb7b2ece1b381436604d6 100644 (file)
@@ -219,20 +219,21 @@ bool namecache_store(const char *name,
        char *key, *value_string;
        int i;
        bool ret;
+       TALLOC_CTX *frame = talloc_stackframe();
 
        if (name_type > 255) {
+               TALLOC_FREE(frame);
                return false; /* Don't store non-real name types. */
        }
 
        if ( DEBUGLEVEL >= 5 ) {
-               TALLOC_CTX *ctx = talloc_stackframe();
                char *addr = NULL;
 
                DEBUG(5, ("namecache_store: storing %d address%s for %s#%02x: ",
                        num_names, num_names == 1 ? "": "es", name, name_type));
 
                for (i = 0; i < num_names; i++) {
-                       addr = print_canonical_sockaddr(ctx,
+                       addr = print_canonical_sockaddr(frame,
                                                        &ip_list[i].ss);
                        if (!addr) {
                                continue;
@@ -242,11 +243,11 @@ bool namecache_store(const char *name,
 
                }
                DEBUGADD(5, ("\n"));
-               TALLOC_FREE(ctx);
        }
 
        key = namecache_key(name, name_type);
        if (!key) {
+               TALLOC_FREE(frame);
                return false;
        }
 
@@ -260,6 +261,7 @@ bool namecache_store(const char *name,
        if (!ipstr_list_make(&value_string, ip_list, num_names)) {
                SAFE_FREE(key);
                SAFE_FREE(value_string);
+               TALLOC_FREE(frame);
                return false;
        }
 
@@ -267,6 +269,7 @@ bool namecache_store(const char *name,
        ret = gencache_set(key, value_string, expiry);
        SAFE_FREE(key);
        SAFE_FREE(value_string);
+       TALLOC_FREE(frame);
        return ret;
 }