Re: [ Code ] Again... I still ahev problems with free() and NULL pointers

From: George (greerga@DRAGON.HAM.MUOHIO.EDU)
Date: 08/04/97


On Mon, 4 Aug 1997, David Klasinc wrote:

>db.c:
>  #define FREE(ptr)       ({ free((ptr)); (ptr) = NULL; })

You'll need to remove the ('s before the { if you use it in a one line if
statement.

like:
  if (ptr)
    FREE(ptr);

>void check_fall(void)
[snip]
>  if (ROOM_AFFECTED(IN_ROOM(ch), RAFF_ACID_RAIN))
>    gen_damage(ch, GET_MAX_HIT(ch) * 10 / 100, SPELL_ACID_RAIN);
>
367-> ?
>    if (ch && ((SECT(IN_ROOM(ch)) == SECT_FLYING)) && (!AFF_FLAGGED(ch, AFF_FLY
>        !(IS_NPC(ch) && MOB_FLAGGED(ch, MOB_WINGS)) &&
>        !(IS_NPC(ch) && MOB_FLAGGED(ch, MOB_NOACT)) &&
>        !(GET_LEVEL(ch) > LVL_IMMORT)) {
>
>... etc etc etc ...

>Char get's extracted in gen_damage()

>#0  0x807ee85 in check_fall () at limits.c:367

After looking over extract_char() some more, it does NOT free PC's, only
mobiles.  A good reason not to free them is because  they are in the memu.
Sooo:

> if (ch && ((SECT(IN_ROOM(ch)) == SECT_FLYING)) && (!AFF_FLAGGED(ch,

Check:                          Result:
1) ch                           ok (they aren't freed yet, just in menu)
2) SECT(IN_ROOM(ch))            ch->inroom == -1 and
                                sector of room -1 == crash
                                (world[-1])

I'd make sure IN_ROOM(ch) != NOWHERE after ch.

--
greerga@muohio.edu me@null.net | Genius may have its limitations, but stupidity
http://www.muohio.edu/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST