24 Jul, 2009, Xrakisis wrote in the 1st comment:
Votes: 0
I tryed to log into my account.. and got this..

Program received signal SIGSEGV, Segmentation fault.
parse_player_list (account=0x0, list=0x4067f000 <Address 0x4067f000 out of bounds>) at account.c:333
333 while (*list != ' ')
(gdb) bt
#0 parse_player_list (account=0x0, list=0x4067f000 <Address 0x4067f000 out of bounds>) at account.c:333
#1 0x00000000 in ?? ()
(gdb) p list
$1 = 0x4067f000 <Address 0x4067f000 out of bounds>

anyone know why?
24 Jul, 2009, Koron wrote in the 2nd comment:
Votes: 0
That's not much to go on, but I would wager it's because your code for accounts is bollocksed. Account itself is null (was it initialized ever?) and list seems to be invalid as well. Totally awesome! Memory problems.
24 Jul, 2009, Xrakisis wrote in the 3rd comment:
Votes: 0
I dont understand….

struct plist *parse_player_list(  ACCOUNT_DATA *account, char *list)
struct plist *p_list;
char tempbuf[MAX_STRING_LENGTH];
bool first = TRUE;
int total_time = 0;

if ((p_list = malloc(sizeof(*p_list))) == NULL)
bug("Parse_player_list: Cannot allocate memory", 0);
p_list->count = 0;

list = account->players;

while (*list != '\0')
char name[20];
char race[20];
char *ptr1, *ptr2;
int played = 0;
bool in_game = FALSE;

name[0] = '\0'; ptr1 = name;
race[0] = '\0'; ptr2 = race;
/* get the name */
while (*list != ' ')
*ptr1++ = *list++;
*ptr1 = '\0'; list++;

/* is that player already logged on ?? */
for (dMob = char_list; dMob; dMob = dMob->next)
if (IS_NPC(dMob)) continue;
if (!str_cmp(dMob->name, name))
in_game = TRUE;

/* get the race */
// while (*list != ' ')
while (*list && *list != ' ')
*ptr2++ = *list++;
*ptr2 = '\0'; list++;

/* get the hours */
while (*list != ' ' && *list != '\0')
played *= 10;
played += *list++ - '0';
if (*list == ' ') list++;

sprintf(tempbuf, " [%d] %-12s %-12s %5d hour%s%s\n\r",
p_list->count, name, race, played, (played == 1) ? "" : "s",
(in_game) ? " (active)" : "");

/* add up */
total_time += played;

if (first)
first = FALSE;
sprintf(p_list->text, "%s", tempbuf);
else strcat(p_list->text, tempbuf);

/* should we add a line with the total time ? */
if (!first)
sprintf(tempbuf, "%34s %5d hour%s total\n\r", " ", total_time, (total_time == 1) ? "" : "s");
strcat(p_list->text, tempbuf);

return p_list;
24 Jul, 2009, Sharmair wrote in the 4th comment:
Votes: 0
Seems pretty clear from this output. Your list argument to this function is invalid and when you
try to dereference that address with *list it crashes. You don't give enough code to see if you are
actually sending a bad list, or you are using the list variable in your function (like in a loop) and
are assigning the bad value there. I would make sure you have whatever you pass as list set up
correctly to start and how you are using it in the function. Also, though again I don't know your
code, does account supposed to be NULL going in like this?
24 Jul, 2009, Xrakisis wrote in the 5th comment:
Votes: 0
It only gives me this problem when i make an alt.. my account.dat file doesnt seem to want to have more than one player registred in it… And im not sure but i dont think account is supposed to be null.. Anything else you need to see to understand my problem better, plz tell me.. Thanks, Xrakisis, Ian Shirm
24 Jul, 2009, Sharmair wrote in the 6th comment:
Votes: 0
When I posted that last post, I only had your first post to go by, looking at the code you did
post it seems account should not be NULL going in. I have not as of this writing read your
whole function, but line 17 of your function (as posted) assigns list with data from your passed
account. I am rather surprised that that line did not crash, but I have seen getting away with
dereferencing NULL itself before (meaning not offset from NULL, if your players member was
the first it would have no offset into the struct). But that is where the invalid list is coming
from. It might help to look at the code that calls this function to see where it is getting
the NULL from.