Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ BUG: Freeing null pointer
BUG: Freeing null pointer
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Robert Powell
Australia (367 posts) Bio
|
Date
| Sun 19 Jun 2005 10:18 AM (UTC) |
Message
| Every now and again i have been getting the following bugs warnings popping up,
Log: [*****] BUG: Freeing null pointer questing.c:942
Log: [*****] BUG: Freeing null pointer questing.c:943
which is the 2 strfree's in the fragment below,
else if (xIS_SET(ch->act,PLR_QUESTOR))
{
if (--ch->pcdata->countdown <= 0)
{
char buf [MAX_STRING_LENGTH];
ch->pcdata->nextquest = 5;
sprintf(buf, "You have run out of time for your quest!\n\rYou may quest again in %d minutes.\n\r",ch->pcdata->nextquest);
send_to_char(buf, ch);
xREMOVE_BIT(ch->act, PLR_QUESTOR);
STRFREE(ch->pcdata->questroom);
STRFREE(ch->pcdata->questarea);
ch->pcdata->questgiver = NULL;
ch->pcdata->countdown = 0;
ch->pcdata->questmob = 0;
}
if (ch->pcdata->countdown > 0 && ch->pcdata->countdown < 3)
{
send_to_char("Better hurry, you're almost out of time for your quest!\n\r",ch);
return;
}
}
Now i understand that the value of questroom and questarea are null, but i cannot work out how come, Should i just check for null and if so assign it a value to free, or is it safe to just the code clean it up, or is there something more wicked going on here that i need to attand too.
Oh also this is the Aurora quest code if that helps any.
Thanks in advance. |
Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated. | Top |
|
Posted by
| Greven
Canada (835 posts) Bio
|
Date
| Reply #1 on Sun 19 Jun 2005 06:35 PM (UTC) |
Message
| It's nothing serious in the current form. The fact that it is giving you the log error make it safe, but coule be annpoying. If you just wanted to eliminate the log errors you could: a) Add a if ( ch->pcdata->questroom )
STRFREE(ch->pcdata->questroom);
This is how it should be done to be safe, and it will clear up your warnings. b) It also duplicates some code, since in STRFREE it has the same check. You could also remove the log message in STRFREE, though I don't recommend this as the log message is useful if there is actually something missing, which may be the case with you.
The fact that both variable are not set could certainly cause issues with the code if they are ever referenced. I would try to find out why they are not being set(presumably when the quest begins? I'm unfamiliar with the code snippet) and correct the issue at the source, as this would also fix the issue. If they are not always set and don't always need to be, the if check above the STRFREE is probably the safest bet. |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
9,171 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top