01 Aug, 2009, Xrakisis wrote in the 1st comment:
Votes: 0
Does anyone see anything wrong with this?



Program received signal SIGSEGV, Segmentation fault.
0x080828d6 in send_to_char (txt=0xbfffc7d4 "{B-={r[ {wInfo{r ]{B=- {g{gDouble Stance is {wON{x!!!!{x\n\r",
ch=0x0) at comm.c:2140
2140 if (txt && ch->desc)
(gdb) p txt
$1 = 0xbfffc7d4 "{B-={r[ {wInfo{r ]{B=- {g{gDouble Stance is {wON{x!!!!{x\n\r"


/*
* Page to one char, new colour version, by Lope.
*/
void send_to_char (const char *txt, CHAR_DATA * ch)
{
const char *point;
char *point2;
char buf[MAX_STRING_LENGTH * 4];
int skip = 0;

buf[0] = '\0';
point2 = buf;
if (txt && ch->desc)
{
if (IS_SET (ch->act, PLR_COLOUR))
{
for (point = txt; *point; point++)
{
if (*point == '{')
{
point++;
skip = colour (*point, ch, point2);
while (skip– > 0)
++point2;
continue;
}
*point2 = *point;
*++point2 = '\0';
}
*point2 = '\0';
write_to_buffer (ch->desc, buf, point2 - buf);
}
else
{
for (point = txt; *point; point++)
{
if (*point == '{')
{
point++;
continue;
}
*point2 = *point;
*++point2 = '\0';
}
*point2 = '\0';
write_to_buffer (ch->desc, buf, point2 - buf);
}
}
return;
}
01 Aug, 2009, Guest wrote in the 2nd comment:
Votes: 0
You'll need to wait for that to happen again and do a backtrace.

# 0x080828d6 in send_to_char (txt=0xbfffc7d4 "{B-={r[ {wInfo{r ]{B=- {g{gDouble Stance is {wON{x!!!!{x\n\r", ch=0x0) at comm.c:2140

ch=0x0 means the character doesn't exit, because its pointer is NULL. Something prior to this function tried to call your double stance message on an invalild character.
01 Aug, 2009, Lobotomy wrote in the 3rd comment:
Votes: 0
Xrakisis said:
Does anyone see anything wrong with this?
Program received signal SIGSEGV, Segmentation fault.
0x080828d6 in send_to_char (txt=0xbfffc7d4 "{B-={r[ {wInfo{r ]{B=- {g{gDouble Stance is {wON{x!!!!{x\n\r",
ch=0x0) at comm.c:2140
2140 if (txt && ch->desc)
(gdb) p txt
$1 = 0xbfffc7d4 "{B-={r[ {wInfo{r ]{B=- {g{gDouble Stance is {wON{x!!!!{x\n\r"

Yes. Your character (ch) pointer is null. Trying to reference a pointer on an already null pointer is an automatic crash; i.e, going "ch->desc" when ch is null is what is crashing it. You need to check for whether each pointer in a series of pointers exists before trying to access the one after it (unless you already know from code ahead of time that the particular pointer will always be non-null). For instance, if you have a->b->c, you need to be sure that both 'a' and 'b' exist before trying to access 'c'; otherwise your program will (probably) crash.

In order to fix your problem, you need to abort the function if ch is null. I.e,

void send_to_char (const char *txt, CHAR_DATA * ch)
{
if( !ch )
return;


Edit: Ninja!

Edit2: Samson is also right in that you still need to do a backtrace on your crash (or just follow the code flow in the file), in order to find out where that function is being called with a null character, as it shouldn't even be doing that in the first place. The above fix I suggested will fix that one particular crash, but it doesn't fix the underlying design problem(s), you see.
Random Picks
0.0/3