Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 Couple bugs
Yesterday, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, DotBot, Google

Members: 0
Guests: 19
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SmaugFUSS Bugfix List » [Bug] New polymorphs can caus...
Forum Rules | Mark all | Recent Posts

[Bug] New polymorphs can cause crashes with no short desc set
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Dec 3, 2005, 6:39 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Bug: New polymorphs can cause crashes with no short desc set
Danger: Critical - Crash bug
Found by: Nick Gammon
Fixed by: Nick Gammon/Samson

---

comm.c, above act_string

Locate:
#define MORPHNAME(ch)   ((ch->morph&&ch->morph->morph)? \
                         ch->morph->morph->short_desc: \
                         IS_NPC(ch) ? ch->short_descr : ch->name)
#define NAME(ch)        ( IS_NPC(ch) ? ch->short_descr : ch->name )


Change to:
#define NAME(ch)        ( IS_NPC(ch) ? ch->short_descr : ch->name )

char *MORPHNAME( CHAR_DATA *ch )
{
   if( ch->morph && ch->morph->morph && ch->morph->morph->short_desc != NULL )
      return ch->morph->morph->short_desc;
   else
      return NAME(ch);
}


polymorph.c, do_morphcreate

Locate:
   if( argument && argument[0] != '\0' && !str_cmp( argument, "copy" ) && temp )
      copy_morph( morph, temp );
   else
      morph->name = str_dup( arg1 );


Change to:
   if( argument && argument[0] != '\0' && !str_cmp( argument, "copy" ) && temp )
      copy_morph( morph, temp );
   else
      morph->name = str_dup( arg1 );
   if( !morph->short_desc || morph->short_desc[0] == '\0' )
      morph->short_desc = str_dup( arg1 );


A newly created morph with no items set will not have a short description. Without a short description the MORPHNAME macro will not work when a morphed immortal uses the goto command. Probably other scenarios where this would crash as well. Additionally, the MORPHNAME macro looked tweaked, so it has been changed to a function instead.

An interesting note though - the macro fix fails to do anything to solve the problem of a morphed imm using goto. It will still crash. Valgrind still says the affected variable is NULL. The MORPHNAME function is only called on 2 particular cases, for $N and $n act strings. That code path is never executed at the point of the crash. So the second change in polymorph.c is ALSO necessary to stop this.

Preexisting morphs which do not have short descriptions set will need to be fixed using the morph editing commands.
       
Pages:<< prev 1 next >>