]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/network/serv_netmail.c
Fix memory leaks in the networker
[citadel.git] / citadel / modules / network / serv_netmail.c
index ce94c1fc4a3741b054fc487f061fb22a6afac96b..90e4e6891f41f272fca90b115f2052dd700b1d1d 100644 (file)
@@ -89,6 +89,7 @@
 #include "context.h"
 #include "netconfig.h"
 #include "netspool.h"
+#include "netmail.h"
 #include "ctdl_module.h"
 
 
@@ -257,9 +258,7 @@ void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc) {
  * Spools out one message from the list.
  */
 void network_spool_msg(long msgnum, 
-                      void *userdata, 
-                      char *working_ignetcfg,
-                      NetMap *the_netmap)
+                      void *userdata)
 {
        SpoolControl *sc;
        int i;
@@ -292,6 +291,8 @@ void network_spool_msg(long msgnum,
                        char *pCh;
                        StrBuf *Subject, *FlatSubject;
 
+                       if (msg->cm_fields['K'] != NULL)
+                               free(msg->cm_fields['K']);
                        if (msg->cm_fields['V'] == NULL){
                                /* local message, no enVelope */
                                StrBuf *Buf;
@@ -435,8 +436,8 @@ void network_spool_msg(long msgnum,
                                if (is_valid_node(NULL, 
                                                  NULL, 
                                                  msg->cm_fields['N'], 
-                                                 working_ignetcfg, 
-                                                 the_netmap) == 0)
+                                                 sc->working_ignetcfg, 
+                                                 sc->the_netmap) == 0)
                                {
                                        ok_to_participate = 1;
                                }
@@ -465,7 +466,7 @@ void network_spool_msg(long msgnum,
                                 */
                                for (nptr = sc->participates; nptr != NULL; nptr = nptr->next) {
 
-                                       if (msg->cm_fields['R'] == NULL) {
+                                       if (msg->cm_fields['R'] != NULL) {
                                                free(msg->cm_fields['R']);
                                        }
                                        msg->cm_fields['R'] = strdup(nptr->name);
@@ -522,8 +523,8 @@ void network_spool_msg(long msgnum,
                        if (is_valid_node(NULL, 
                                          NULL, 
                                          mptr->remote_nodename, 
-                                         working_ignetcfg, 
-                                         the_netmap) != 0)
+                                         sc->working_ignetcfg, 
+                                         sc->the_netmap) != 0)
                        {
                                syslog(LOG_ERR, "Invalid node <%s>\n", mptr->remote_nodename);
                                send = 0;