[bug] bpl21 boards

From: Russell Ryan (rjwr10@hotmail.com)
Date: 08/05/02


Hi again all,

when I was messing around with bpl21, I wrote a message on the immortal board (regular message, ie not blank etc.) and then removed it, I shutdown the mud and got an assertion failure in dbgheap.c, backtraced to free() then to Board_clear_board() called by Board_clear_all. 

heres the bit of code where it crashes

void Board_clear_board(int board_type)
{
  int i;

  for (i = 0; i < MAX_BOARD_MESSAGES; i++) {
    if (MSG_HEADING(board_type, i))
      free(MSG_HEADING(board_type, i));       <--- this line
*snip* 
board type = 1(immortal board's number), i=6 in this call 
(it was the 6th message written to the board)

so its crashing when it frees all the boards on the mud

oh btw, ms visual c++ 6, windows me

I then unzipped a fresh copy of bpl21 and compiled it. I wrote a message on the board, removed it, then shutdown and the same thing happened so its not anything I had added to it. It only seems to happen when I remove the message. I can write to the board, etc, shutdown and be fine. 

After taking a look at Board_remove_msg(...) in boards.c I came to this conclusion:
After all the checks to see if its ok to remove the message, heres the code that actually removes it:

  if (msg_storage[slot_num])
    free(msg_storage[slot_num]);
  msg_storage[slot_num] = 0;
  msg_storage_taken[slot_num] = 0;
  if (MSG_HEADING(board_type, ind))
    free(MSG_HEADING(board_type, ind));

MSG_HEADING is a char* and after its free'd its not set to NULL, I changed the last two lines to this:
  if (MSG_HEADING(board_type, ind)) {
    free(MSG_HEADING(board_type, ind));
    MSG_HEADING(board_type, ind) = NULL;
}

and that fixed it for me

Just wondering if anyone else came across this and if so how they fixed it 

thanks,
rj ryan :)

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT