[patch] smbspool memory leak...

Michael Sweet mike at easysw.com
Thu Oct 10 20:50:29 GMT 2002


All,

I discovered this last weekend when my Windows PC forgot it had a
wireless adapter...  Two days later smbspool (which was trying to
print a file) was using 380MB on my laptop... :)

Attached is a patch that makes sure that cli_shutdown() is called
on all errors so that the memory it uses is freed.

-- 
______________________________________________________________________
Michael Sweet, Easy Software Products                  mike at easysw.com
Printing Software for UNIX                       http://www.easysw.com
-------------- next part --------------
Index: smbspool.c
===================================================================
RCS file: /cvsroot/samba/source/client/smbspool.c,v
retrieving revision 1.4.4.6
diff -u -r1.4.4.6 smbspool.c
--- smbspool.c	28 Feb 2002 01:52:07 -0000	1.4.4.6
+++ smbspool.c	10 Oct 2002 20:46:44 -0000
@@ -307,18 +307,21 @@
   if (!cli_set_port(c, SMB_PORT))
   {
     fputs("ERROR: cli_set_port() failed...\n", stderr);
+    cli_shutdown(c);
     return (NULL);
   }
 
   if (!cli_connect(c, server, &ip))
   {
     fputs("ERROR: cli_connect() failed...\n", stderr);
+    cli_shutdown(c);
     return (NULL);
   }
 
   if (!cli_session_request(c, &calling, &called))
   {
     fputs("ERROR: cli_session_request() failed...\n", stderr);
+    cli_shutdown(c);
     return (NULL);
   }
 
@@ -339,6 +342,7 @@
 			 workgroup))
   {
     fprintf(stderr, "ERROR: SMB session setup failed: %s\n", cli_errstr(c));
+    cli_shutdown(c);
     return (NULL);
   }
 


More information about the samba-technical mailing list