source4/client/client.c: Possible memory leaks
authorSlava Semushin <php-coder@altlinux.org>
Fri, 12 Jun 2009 11:32:48 +0000 (13:32 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 18 Jun 2009 03:49:26 +0000 (13:49 +1000)
Patch for bug #6446

cppcheck found 2 possible memory leaks:

    [./source4/client/client.c:3305]: (error) Memory leak: base_directory
    [./source4/client/client.c:3305]: (error) Memory leak: desthost

Patch in attach.

source4/client/client.c

index 018be297610cbf85e95851298702ffae358aa074..82aeef3290045d4b5601a9011014c2b9aa0059a4 100644 (file)
@@ -3290,15 +3290,18 @@ static int do_message_op(const char *netbios_name, const char *desthost,
                        lp_gensec_settings(ctx, cmdline_lp_ctx)))
                return 1;
 
-       if (base_directory) 
+       if (base_directory) {
                do_cd(ctx, base_directory);
+               free(base_directory);
+       }
        
        if (cmdstr) {
                rc = process_command_string(ctx, cmdstr);
        } else {
                rc = process_stdin(ctx);
        }
-  
+
+       free(desthost);
        talloc_free(mem_ctx);
 
        return rc;