* if we delete the last message, msglist[num_msgs - 1] points into an invalid area
authorWilfried Göesgens <willi@citadel.org>
Sun, 7 Feb 2010 12:54:27 +0000 (12:54 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 7 Feb 2010 12:54:27 +0000 (12:54 +0000)
* qrbuf.QRhighest is set to 0 if the room is empty; this will most probably fix the problems with empty rooms appearing to have unread messages.

citadel/msgbase.c

index 91e8e10a16dc119e8ad8898589cebb179efae2cf..85809adb3cd477581fd109b477d1b2ac5522fe09 100644 (file)
@@ -4225,7 +4225,10 @@ int CtdlDeleteMessages(char *room_name,          /* which room */
                cdb_store(CDB_MSGLISTS, &qrbuf.QRnumber, (int)sizeof(long),
                          msglist, (int)(num_msgs * sizeof(long)));
 
-               qrbuf.QRhighest = msglist[num_msgs - 1];
+               if (num_msgs > 0)
+                       qrbuf.QRhighest = msglist[num_msgs - 1];
+               else
+                       qrbuf.QRhighest = 0;
        }
        CtdlPutRoomLock(&qrbuf);