Fix missing error cleanup noticed by Derrell.
authorJeremy Allison <jra@samba.org>
Sat, 1 Dec 2007 05:57:43 +0000 (21:57 -0800)
committerJeremy Allison <jra@samba.org>
Sat, 1 Dec 2007 05:57:43 +0000 (21:57 -0800)
Jeremy.

source/libsmb/libsmbclient.c

index 3990a29f4a2454e7fe44301ef74a4fd79adf6aa7..26ff339a1ad3a1e694f6d95cc2c2fd245e140e8c 100644 (file)
@@ -2777,7 +2777,6 @@ smbc_opendir_ctx(SMBCCTX *context,
                 struct ip_service *ip_list;
                 struct ip_service server_addr;
                 struct user_auth_info u_info;
-                struct cli_state *cli;
 
                if (share[0] != (char)0 || path[0] != (char)0) {
 
@@ -2838,6 +2837,7 @@ smbc_opendir_ctx(SMBCCTX *context,
                 for (i = 0; i < count && i < max_lmb_count; i++) {
                        char addr[INET6_ADDRSTRLEN];
                        char *wg_ptr = NULL;
+                       struct cli_state *cli = NULL;
 
                        print_sockaddr(addr, sizeof(addr), &ip_list[i].ss);
                         DEBUG(99, ("Found master browser %d of %d: %s\n",
@@ -2850,17 +2850,20 @@ smbc_opendir_ctx(SMBCCTX *context,
                                                        &wg_ptr);
                        /* cli == NULL is the master browser refused to talk or
                           could not be found */
-                       if ( !cli )
+                       if (!cli) {
                                continue;
+                       }
 
                        workgroup = talloc_strdup(frame, wg_ptr);
                        server = talloc_strdup(frame, cli->desthost);
+
+                        cli_shutdown(cli);
+
                        if (!workgroup || !server) {
                                errno = ENOMEM;
                                TALLOC_FREE(frame);
                                return NULL;
                        }
-                        cli_shutdown(cli);
 
                         DEBUG(4, ("using workgroup %s %s\n",
                                   workgroup, server));