]> code.citadel.org Git - citadel.git/commitdiff
* entmsg(): Don't corrupt the msg_arr[] when replying to a message in a room
authorMichael Hampton <io_error@uncensored.citadel.org>
Wed, 19 Mar 2003 11:48:06 +0000 (11:48 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Wed, 19 Mar 2003 11:48:06 +0000 (11:48 +0000)
citadel/ChangeLog
citadel/messages.c

index ab3f0c7163a924599ff54391d7555083ca734c87..cc3122d50a806c142ce7f79afbb9e496402e039b 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 605.24  2003/03/19 11:48:06  error
+ * entmsg(): Don't corrupt the msg_arr[] when replying to a message in a room
+
  Revision 605.23  2003/03/19 04:04:56  ajc
  * Dropped support for GDBM and for versions of Berkeley DB prior to 4.1
 
@@ -4577,4 +4580,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 4b0c777f50ab862a282bc79321c339aebade4e93..a8cf2d1eb764a35d8eb5b61842ad4c266da110f6 100644 (file)
@@ -1009,6 +1009,7 @@ int entmsg(CtdlIPC *ipc,
        FILE *fp;
        char subject[SIZ];
        struct ctdlipcmessage message;
+       unsigned long *msgarr = NULL;
        int r;                  /* IPC response code */
 
        if (c > 0)
@@ -1098,12 +1099,11 @@ int entmsg(CtdlIPC *ipc,
         * tell upon saving whether someone else has posted too.
         */
        num_msgs = 0;
-       free(msg_arr); msg_arr = NULL;
-       r = CtdlIPCGetMessages(ipc, LastMessages, 1, NULL, &msg_arr, buf);
+       r = CtdlIPCGetMessages(ipc, LastMessages, 1, NULL, &msgarr, buf);
        if (r / 100 != 1) {
                scr_printf("%s\n", buf);
        } else {
-               for (num_msgs = 0; msg_arr[num_msgs]; num_msgs++)
+               for (num_msgs = 0; msgarr[num_msgs]; num_msgs++)
                        ;
        }
 
@@ -1134,27 +1134,30 @@ int entmsg(CtdlIPC *ipc,
                return (1);
        }
 
-       if (num_msgs >= 1) highmsg = msg_arr[num_msgs - 1];
+       if (num_msgs >= 1) highmsg = msgarr[num_msgs - 1];
 
-       free(msg_arr); msg_arr = NULL;
-       r = CtdlIPCGetMessages(ipc, NewMessages, 0, NULL, &msg_arr, buf);
+       if (msgarr) free(msgarr);
+       msgarr = NULL;
+       r = CtdlIPCGetMessages(ipc, NewMessages, 0, NULL, &msgarr, buf);
        if (r / 100 != 1) {
                scr_printf("%s\n", buf);
        } else {
-               for (num_msgs = 0; msg_arr[num_msgs]; num_msgs++)
+               for (num_msgs = 0; msgarr[num_msgs]; num_msgs++)
                        ;
        }
 
        /* get new highest message number in room to set lrp for goto... */
-       maxmsgnum = msg_arr[num_msgs - 1];
+       maxmsgnum = msgarr[num_msgs - 1];
 
        /* now see if anyone else has posted in here */
        b = (-1);
        for (a = 0; a < num_msgs; ++a) {
-               if (msg_arr[a] > highmsg) {
+               if (msgarr[a] > highmsg) {
                        ++b;
                }
        }
+       if (msgarr) free(msgarr);
+       msgarr = NULL;
 
        /* In the Mail> room, this algorithm always counts one message
         * higher than in public rooms, so we decrement it by one.