Fixed another possible memleak in cli_initialise()
authorTim Potter <tpot@samba.org>
Mon, 6 Aug 2001 23:29:25 +0000 (23:29 +0000)
committerTim Potter <tpot@samba.org>
Mon, 6 Aug 2001 23:29:25 +0000 (23:29 +0000)
(This used to be commit 4c9f010a1eef81addfea0315bef81570bc604f8a)

source3/libsmb/clientgen.c

index 79fa224e8f0fda4afc891c780a647f8f7cd18f15..ba852dea52b8314b59ffb23f982ef33a61ea7df6 100644 (file)
@@ -152,11 +152,14 @@ initialise a client structure
 ****************************************************************************/
 struct cli_state *cli_initialise(struct cli_state *cli)
 {
+        BOOL alloced_cli = False;
+
        if (!cli) {
                cli = (struct cli_state *)malloc(sizeof(*cli));
                if (!cli)
                        return NULL;
                ZERO_STRUCTP(cli);
+                alloced_cli = True;
        }
 
        if (cli->initialised) {
@@ -201,6 +204,9 @@ struct cli_state *cli_initialise(struct cli_state *cli)
         safe_free(cli->inbuf);
         safe_free(cli->outbuf);
 
+        if (alloced_cli)
+                safe_free(cli);
+
         return NULL;
 }