Fix CID 461 - resource leak on error.
authorJeremy Allison <jra@samba.org>
Wed, 9 Jan 2008 02:51:55 +0000 (18:51 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 9 Jan 2008 02:51:55 +0000 (18:51 -0800)
Jeremy.
(This used to be commit eea07b0c83985af60395f8a31de5bac4e5398cff)

source3/libsmb/clidfs.c

index 77419b4a1ad7d1b54fbad777964292e8defc30c5..16582f80490693db73d3151031828a8839b1a509 100644 (file)
@@ -156,6 +156,9 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
        /* have to open a new connection */
        if (!(c=cli_initialise()) || (cli_set_port(c, port) != port)) {
                d_printf("Connection to %s failed\n", server_n);
+               if (c) {
+                       cli_shutdown(c);
+               }
                return NULL;
        }
        status = cli_connect(c, server_n, &ss);
@@ -163,6 +166,7 @@ static struct cli_state *do_connect(TALLOC_CTX *ctx,
                d_printf("Connection to %s failed (Error %s)\n",
                                server_n,
                                nt_errstr(status));
+               cli_shutdown(c);
                return NULL;
        }