Hey folks,
When page_to_char gets passed a lot of data from another function, I get a
crash with
the GDB output looking like this:
#0 0x809153c in colour (type=71, ch=0x5b1b2039, string=0xbfffa432 "") at
comm.c:3680
3680 if( ch && IS_NPC( ch ) )
(gdb) back
#0 0x809153c in colour (type=71, ch=0x5b1b2039, string=0xbfffa432 "") at
comm.c:3680
#1 0x8091c14 in page_to_char (txt=0x38363232 <Address 0x38363232 out of
bounds>, ch=0x5b1b2039) at comm.c:4035
#2 0x6d313b32 in ?? ()
Cannot access memory at address 0x335b1b5b
Im not that much of a wiz with GDB, can someone give me a hint as to what
to check next?
It works fine as long as the data I'm adding to the buffer is not alot. It
works any other time.
The page_to_char comes from Lopes 2.0 but the colour code is modified and
listed below.
int colour( char type, CHAR_DATA *ch, char *string )
{
char code[ 20 ];
char *p = '\0';
// if( IS_NPC( ch ) )
if( ch && IS_NPC( ch ) )
return( 0 );
switch( type )
{
default:
strcpy( code, CLR_NORMAL );
break;
case 'x':
strcpy( code, CLR_NORMAL );
break;
case 'g':
strcpy( code, CLR_GREEN );
break;
case 'o':
strcpy( code, CLR_BROWN );
break;
case 'r':
strcpy( code, CLR_RED );
break;
case 'u':
strcpy( code, CLR_BLUE );
break;
case 'm':
strcpy( code, CLR_MAGENTA );
break;
case 'c':
strcpy( code, CLR_CYAN );
break;
case 'w':
strcpy( code, CLR_WHITE );
break;
case 'G':
strcpy( code, CLR_GREEN_BOLD);
break;
case 'O':
case 'y': //high brown oryellow
strcpy (code, CLR_YELLOW);
break;
case 'R':
strcpy(code, CLR_RED_BOLD);
break;
case 'U':
strcpy( code, CLR_BLUE_BOLD );
break;
case 'M':
strcpy( code, CLR_MAGENTA_BOLD );
break;
case 'C':
strcpy( code, CLR_CYAN_BOLD );
break;
case 'W':
strcpy( code, CLR_WHITE_BOLD );
break;
case 'B':
strcpy( code, CLR_GREY );
break;
case 'b':
sprintf( code, "%c", '\a' );
break;
case 'n':
strcpy( code, "\n\r" );
break;
case '@':
sprintf( code, "%c", '@' );
break;
}
p = code;
while( *p != '\0' )
{
*string = *p++;
*++string = '\0';
}
return( strlen( code ) );
}
Any help is appreciated.
Keith (lost in a morass of colour) Mervine