s3-spoolss: Don't leak memory on the session counter list.
authorAndreas Schneider <asn@samba.org>
Fri, 10 Sep 2010 14:06:24 +0000 (16:06 +0200)
committerAndreas Schneider <asn@samba.org>
Fri, 10 Sep 2010 14:10:46 +0000 (16:10 +0200)
Thanks G√ľnther, please check.

source3/include/proto.h
source3/rpc_server/srv_spoolss_nt.c
source3/smbd/server.c

index 0b54932135f87535b3098f0422cf27152f4b52b5..5e2e0bff3d42d089f21c8752c0d3775c8b8d17a8 100644 (file)
@@ -4386,6 +4386,7 @@ NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
                      bool *is_data_outstanding);
 
 /* The following definitions come from rpc_server/srv_spoolss_nt.c  */
+void srv_spoolss_cleanup(void);
 
 void do_drv_upgrade_printer(struct messaging_context *msg,
                            void *private_data,
index 573faaf979e4c9455929b3629ae8e3b81501ec1f..b5e2ddbdc639b85152457ba57546cb45f490407c 100644 (file)
@@ -1462,6 +1462,18 @@ static bool srv_spoolss_drv_upgrade_printer(const char *drivername,
        return true;
 }
 
+void srv_spoolss_cleanup(void)
+{
+       struct printer_session_counter *session_counter;
+
+       for (session_counter = counter_list;
+            session_counter != NULL;
+            session_counter = counter_list) {
+               DLIST_REMOVE(counter_list, session_counter);
+               TALLOC_FREE(session_counter);
+       }
+}
+
 /**********************************************************************
  callback to receive a MSG_PRINTER_DRVUPGRADE message and interate
  over all printers, upgrading ones as necessary
index c9ae742b990bf489e0a3b466e8c0ad65b0b97381..247cbb84d565feba88e10d2b32d264c4f28ed296 100644 (file)
@@ -807,6 +807,13 @@ static bool spoolss_init_cb(void *ptr)
        return nt_printing_tdb_migrate(msg_ctx);
 }
 
+static bool spoolss_shutdown_cb(void *ptr)
+{
+       srv_spoolss_cleanup();
+
+       return true;
+}
+
 /****************************************************************************
  main program.
 ****************************************************************************/
@@ -1165,7 +1172,7 @@ extern void build_options(bool screen);
         * can't register it twice.
         */
        spoolss_cb.init = spoolss_init_cb;
-       spoolss_cb.shutdown = NULL;
+       spoolss_cb.shutdown = spoolss_shutdown_cb;
        spoolss_cb.private_data = smbd_server_conn->msg_ctx;
 
        /* Spoolss depends on a winreg pipe, so start it first. */