* if the message is not valid, try to free the message pointer in message_free
authorWilfried Göesgens <willi@citadel.org>
Sat, 20 Jan 2007 15:30:06 +0000 (15:30 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sat, 20 Jan 2007 15:30:06 +0000 (15:30 +0000)
* be paranoid about message pointers being non initialized

citadel/euidindex.c
citadel/msgbase.c
citadel/serv_calendar.c
citadel/serv_expire.c
citadel/serv_network.c
citadel/serv_smtp.c

index dd9b171dc6e6d27b684cd88021535d671a883cd2..752437777ce979bbe4a544fde879ecd0e5ae7163 100644 (file)
@@ -154,7 +154,7 @@ void index_message_by_euid(char *euid, struct ctdlroom *qrbuf, long msgnum) {
  * Called by rebuild_euid_index_for_room() to index one message.
  */
 void rebuild_euid_index_for_msg(long msgnum, void *userdata) {
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
 
        msg = CtdlFetchMessage(msgnum, 0);
        if (msg == NULL) return;
index 2b09ed2b9fa71eb62753c853d34306dabbaa7198..badbc8f7cc351e2bf6ab01e3e127289ba8285414 100644 (file)
@@ -532,7 +532,7 @@ int CtdlForEachMessage(int mode, long ref, char *search_string,
        int num_processed = 0;
        long thismsg;
        struct MetaData smi;
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        int is_seen = 0;
        long lastold = 0L;
        int printed_lastold = 0;
@@ -1109,7 +1109,11 @@ void CtdlFreeMessage(struct CtdlMessage *msg)
 {
        int i;
 
-       if (is_valid_message(msg) == 0) return;
+       if (is_valid_message(msg) == 0) 
+       {
+               if (msg != NULL) free (msg);
+               return;
+       }
 
        for (i = 0; i < 256; ++i)
                if (msg->cm_fields[i] != NULL) {
@@ -1902,7 +1906,7 @@ void cmd_msg2(char *cmdbuf)
 void cmd_msg3(char *cmdbuf)
 {
        long msgnum;
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        struct ser_ret smr;
 
        if (CC->internal_pgm == 0) {
index 457ca654f541878a4b14da3ab838d7f54e49ebc6..7833ab84fd00866680c425681379bca7b091934e 100644 (file)
@@ -376,7 +376,7 @@ void ical_locate_part(char *name, char *filename, char *partnum, char *disp,
  * Respond to a meeting request.
  */
 void ical_respond(long msgnum, char *partnum, char *action) {
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        struct ical_respond_data ird;
 
        if (
@@ -606,7 +606,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
        char uid[SIZ];
        char hold_rm[ROOMNAMELEN];
        long msgnum_being_replaced = 0;
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        struct original_event_container oec;
        icalcomponent *original_event;
        char *serialized_event = NULL;
@@ -712,7 +712,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) {
  * passes it up to ical_update_my_calendar_with_reply() for processing.
  */
 void ical_handle_rsvp(long msgnum, char *partnum, char *action) {
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        struct ical_respond_data ird;
        int ret;
 
@@ -876,7 +876,7 @@ int ical_ctdl_is_overlap(
  */
 void ical_hunt_for_conflicts_backend(long msgnum, void *data) {
        icalcomponent *cal;
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        struct ical_respond_data ird;
        struct icaltimetype t1start, t1end, t2start, t2end;
        icalproperty *p;
@@ -993,7 +993,7 @@ void ical_hunt_for_conflicts(icalcomponent *cal) {
  * Hunt for conflicts (Phase 1 -- retrieve the object and call Phase 2)
  */
 void ical_conflicts(long msgnum, char *partnum) {
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        struct ical_respond_data ird;
 
        msg = CtdlFetchMessage(msgnum, 1);
@@ -1133,7 +1133,7 @@ void ical_add_to_freebusy(icalcomponent *fb, icalcomponent *cal) {
  */
 void ical_freebusy_backend(long msgnum, void *data) {
        icalcomponent *cal;
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        struct ical_respond_data ird;
 
        cal = (icalcomponent *)data;
@@ -1336,7 +1336,7 @@ void ical_freebusy(char *who) {
  */
 void ical_getics_backend(long msgnum, void *data) {
        icalcomponent *encaps, *c;
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        struct ical_respond_data ird;
 
        encaps = (icalcomponent *)data;
index 56fb499fca52a04ed2a3fb31ab9390dad3cb3db6..542c1701f18b07e760d6423617805013db9241de 100644 (file)
@@ -126,7 +126,7 @@ void GatherPurgeMessages(struct ctdlroom *qrbuf, void *data) {
        struct ExpirePolicy epbuf;
        long delnum;
        time_t xtime, now;
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        int a;
         struct cdbdata *cdbfr;
        long *msglist = NULL;
@@ -651,7 +651,7 @@ int PurgeEuidIndexTable(void) {
        struct EPurgeList *el = NULL;
        struct EPurgeList *eptr; 
        long msgnum;
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
 
        /* Phase 1: traverse through the table, discovering old records... */
        lprintf(CTDL_DEBUG, "Purge EUID index: phase 1\n");
index 2b4ca3e12896fd9f48d243b26b1a112583d46b56..fb18445ed23c0e575454542ff0dfbfb78bd556de 100644 (file)
@@ -425,12 +425,12 @@ void cmd_snet(char *argbuf) {
 void network_deliver_digest(struct SpoolControl *sc) {
        char buf[SIZ];
        int i;
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        long msglen;
        long msgnum;
        char *instr = NULL;
        size_t instr_len = SIZ;
-       struct CtdlMessage *imsg;
+       struct CtdlMessage *imsg = NULL;
        struct namelist *nptr;
 
        if (sc->num_msgs_spooled < 1) {
@@ -530,7 +530,7 @@ void network_deliver_list(struct CtdlMessage *msg, struct SpoolControl *sc) {
        long msgnum;
        char *instr = NULL;
        size_t instr_len = SIZ;
-       struct CtdlMessage *imsg;
+       struct CtdlMessage *imsg = NULL;
        struct namelist *nptr;
 
        /* Don't do this if there were no recipients! */
@@ -1328,7 +1328,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) {
  * from the inbound queue 
  */
 void network_process_buffer(char *buffer, long size) {
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        long pos;
        int field;
        struct recptypes *recp = NULL;
index 255dfcf2ae7b4d5809a6286a542b27ef30d14730..ad1bda2f787fa3946bfb854153a5d2738638e8b2 100644 (file)
@@ -688,7 +688,7 @@ void smtp_rcpt(char *argbuf) {
  */
 void smtp_data(void) {
        char *body;
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        long msgnum = (-1L);
        char nowstamp[SIZ];
        struct recptypes *valid;
@@ -1513,7 +1513,7 @@ int smtp_purge_completed_deliveries(char *instr) {
  * Called by smtp_do_queue() to handle an individual message.
  */
 void smtp_do_procmsg(long msgnum, void *userdata) {
-       struct CtdlMessage *msg;
+       struct CtdlMessage *msg = NULL;
        char *instr = NULL;
        char *results = NULL;
        int i;