Mem-leak in Client::QuestTroupe()
Around line 2120 in client.cpp:
Code:
Message(13,"Attempting to delete petition number: %i",atoi(sep->argplus[1])); Here is the corrected code piece: Code:
Message(13,"Attempting to delete petition number: %i",atoi(sep->argplus[1])); Markus |
Maybe remove result at all since nobody cares for the result set here anyway.
|
Okay, correct me if I am wrong but if RunQuery() returns true, mysql_free_result() must be called on the result pointer. Otherwise, if RunQuery() returns false, mysql_fee_result() must not be freed.
If thats true, here are some locations where result is not, or uncorrectly freed. If thats wrong, ignore all of the bugs below. All line numbers from latest CVS source. client.cpp - Client::NormalGM() around line 4104 in handler for "#spawnfix": mysql_free_result() is called when RunQuery() returns false. Possible GPF. And at line 4095 there is a problem with mysql_free_result() if the second RunQuery call fails. In this case, result of the first RunQuery() is freed twice. client.cpp - Client::NormalUser() around line 4359 in handler for "#viewmessage": result pointer used in two RunQuery() calls without freeing after first use. Memory leak. Looks like result of second RunQuery() isn't used anyway so maybe remove it. client.cpp - Database::CheckGuildDoor() around line 6981: if {} else {} block with return statements. code below won't ever be reached. might want to ignore this... wont be a problem anyway. client.cpp - Client::VHServerOp() around line 1590: result pointer is never freed. Memory leak. client.cpp - Client::LeadGM() around line 3215: result poitner is never freed. Memory leak. Regards, Markus |
Yeah.. freeing if RunQuery returned FAIL..is quite bad...I'll check all of those you mentioned out or atleast forward it to someone else
|
If you didn't have time to check this yet, I have made a patch against the latest CVS source that fixes all this stuff in client.cpp
Apply with "patch client.cpp <patchfile" Code:
--- client.cpp 2003-08-05 10:18:30.000000000 +0200 Markus |
I hate to ask this, but can you attatch it in text form. I can't paste properly off the forums, and I don't feel like reformatting a large patch file..
Thanks! Also, CVS updated last night (I had to fix some of the NewSource jobs) , so can you check the patch against last night CVS build ? |
This patch is against the latest CVS already.
And I hate to ask that too, but how can I attach a file to my posts? Anyway, if it's easier for you I can send you an email as well or put this stuff on some ftp server. Regards, Markus |
I didnt notice that attatchments had been disabled... Sorry bout that..
I'll send you a PM... |
Re: Mem-leak in Client::QuestTroupe()
Quote:
Code:
if (database.RunQuery(query, MakeAnyLenString(&query, "DELETE from petitions where petid=%i",atoi(sep->argplus[1])), errbuf)) { Code:
strcpy(errbuf, "DBcore::RunQuery: No Result"); Another note, it'd be good to have: Code:
if (database.RunQuery(query, MakeAnyLenString(...), ...) { |
All times are GMT -4. The time now is 10:03 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.