Re: A Circle 2.2 thingy

From: Gary (gwalicze@students.uiuc.edu)
Date: 08/10/95


On Thu, 10 Aug 1995, Ron Poulton wrote:

> > Hi all another question..   Below is the stats on a char.. which crashes the mud
> >         everytime the PC tries to kill a fido.. 
> > 
> > My first thought was possibly the PC name, any Ideas??
> > 
> > anyhow the char is going to be re-done with a new name... to see if that one 
> > fixes the problem.
> 
> I've had serious problems when it comes to strings being too long; ie, I 
> set a string which can only be up to 40 characters in length to a 
> 50-character string, and 'gcc' doesn't seem to catch this in error 
> checking.  Otherwise, I can't see what would be wrong.
In C, when you set the array length of a string all it does is allocate 
memory for it, it doesn't use the length of the array for anything else ( 
like writing to the array) so, you can write data past the end of the 
array, which will cause problems because it will probably be overwriting 
other needed data. The best thing to do is put in code so that a 
character string longer than the array can't be entered.

> 
> I noticed that routines I wrote that accessed the descriptor data for a 
> character (or a mobile) crashed when the routine attempted to access a 
> mobile.  It sounds like this single character is crashing the game, 
> though, however many things could be considered without knowing more 
> about the MUD.  Seems odd that a single character would crash things.. be 
> an idea to look at the stats, see the differences and try to duplicate 
> them bit by bit to find out what's wrong.

First when accessing ANYTHING through a pointer, make a check to make 
sure the pointer is not null. Accessing a null pointer is the quickest 
way th crash your mud. As for your specific problem, descriptor_data is 
the data about the network connection for a character, so unless someone 
is switched into the mob your code will try to access data from a null 
pointer and *CRASH*

-- Gary



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