Help with another crash


#1

Hello everyone:
Link to github where code can be found: https://github.com/ptrayal/Project_Twilight

So, this is my problem. When I go into hedit and want to restrict a help file to a particular race subtype (in this case, lets say a vampire clan), it crashes.

This is what happens:
> help_edit lasombra
>
>
> Essential Fields.
> Trust: [ -1] Keywords: Lasombra
> Races: (null)
> Clans: (null)
>
> Formatted fields:
> Topic: Vampire Clan: Lasombra
> Syntax: (null)
> Body:
> Clan Lasombra is the one leading one of the Jyhad’s two major sects, the
> Sabbat, and with good reason; manipulative and efficient, sometimes
> ruthless and always long-term planners and leaders of kine and Cainite
> alike, these masters of shadows have dwelled in darkness for ages
> untold, spinning their weaves and plans in the pursuit of power.
>
> Their major strength coming not from the ability to physically bend
> shadowy tendrils to their will and using it as its extensions to crush
> their enemies but from their ability to blend in and take charge, Clan
> Lasombra has been influencing the Christian Church for well over a
> millenium, in the Dark Ages manipulating it to gain awesome political
> influence over entire nations; even today, many of its members claim a
> priest’s robe, or are somehow tied to a monastery or similar sanctuary
> of a divine nature.
>
> dfClan Disciplines: Obtenebration, Potence, Dominate
>
> See also: KINDRED; VAMPIRE; BLOODLINES
>
> Website: (null)
>
> Do not use in conjunction with formatted fields.
> Unformatted:
> (null)
> Type ‘done’ to exit the editor.
>
>
> race vampire

And this is what GDB shows me:

Program received signal SIGSEGV, Segmentation fault.
__strstr_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S:40
40	../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S: No such file or directory.
(gdb) bt
#0  __strstr_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S:40
#1  0x0000555555628dad in hedit_races (ch=0x555555ba1480, argument=<optimized out>) at olc_act.c:6764
#2  0x000055555562f920 in hedit (ch=0x555555ba1480, argument=0x555555b9e8a2 "vampire", type=type@entry=0) at olc.c:1447
#3  0x0000555555632dd3 in run_olc_editor (d=<optimized out>) at olc.c:76
#4  0x000055555558f74b in game_loop_unix (control=4) at comm.c:730
#5  0x000055555558fd05 in main (argc=2, argv=0x7fffffffdfd8) at comm.c:962
(gdb) frame 0
#0  __strstr_sse2_unaligned () at ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S:40
40	in ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S
(gdb) list
35	in ../sysdeps/x86_64/multiarch/strstr-sse2-unaligned.S
(gdb) info locals
No locals.
(gdb) frame 1
#1  0x0000555555628dad in hedit_races (ch=0x555555ba1480, argument=<optimized out>) at olc_act.c:6764
6764		if ( strstr( help->races, name ) != NULL )
(gdb) list
6759			return FALSE;
6760		}
6761	
6762		name[0] = UPPER( name[0] );
6763	
6764		if ( strstr( help->races, name ) != NULL )
6765		{
6766			help->races = string_replace( help->races, name, "\0" );
6767			help->races = string_unpad( help->races );
6768	
(gdb) info locals
help = 0x5555559447e0
name = "Vampire", '\000' <repeats 4088 times>
buf = '\000' <repeats 4095 times>
__FUNCTION__ = "hedit_races"
(gdb) frame 2
#2  0x000055555562f920 in hedit (ch=0x555555ba1480, argument=0x555555b9e8a2 "vampire", type=type@entry=0) at olc.c:1447
1447			if ( (*hedit_table[cmd].olc_fun) ( ch, argument ) )
(gdb) list
1442		{
1443		  for ( cmd = 0; hedit_table[cmd].name != NULL; cmd++ )
1444		  {
1445		if ( !str_prefix( command, hedit_table[cmd].name ) )
1446		{
1447			if ( (*hedit_table[cmd].olc_fun) ( ch, argument ) )
1448			return;
1449		}
1450		  }
1451		}
(gdb) info locals
pHelp = <optimized out>
cmd = <optimized out>
command = "race", '\000' <repeats 251 times>
arg = "race vampire", '\000' <repeats 243 times>
__FUNCTION__ = "hedit"

Any thoughts on what is going wrong here would be appreciated.

Regards,
Arholly


#2

I’m not 100% sure, but it looks like strstr() isn’t doing a very good job of handling help->races being NULL. I don’t use strstr() so i don’t know if it has any method of handling NULL pointers, but that’s where I’d start looking.