Quote:
Originally Posted by Deawin
Around line 2120 in client.cpp:
Code:
Message(13,"Attempting to delete petition number: %i",atoi(sep->argplus[1]));
if (database.RunQuery(query, MakeAnyLenString(&query, "DELETE from petitions where petid=%i",atoi(sep->argplus[1])), errbuf, &result)) {
safe_delete_array(query);
LogFile->write(EQEMuLog::Normal,"Delete petition request from %s, petition number:", GetName(), atoi(sep->argplus[1]) );
}
//mysql_free_result(result); // If uncommented crashes zone. :/
If RunQuery() succeedes, result is never freed. I just moved the commented mysql_free_result below the if {} block into it.
Here is the corrected code piece:
Code:
Message(13,"Attempting to delete petition number: %i",atoi(sep->argplus[1]));
if (database.RunQuery(query, MakeAnyLenString(&query, "DELETE from petitions where petid=%i",atoi(sep->argplus[1])), errbuf, &result)) {
safe_delete_array(query);
mysql_free_result(result);
LogFile->write(EQEMuLog::Normal,"Delete petition request from %s, petition number:", GetName(), atoi(sep->argplus[1]) );
}
|
Hmm, if i remember how stuff works right, it'd be better to change it to:
Code:
if (database.RunQuery(query, MakeAnyLenString(&query, "DELETE from petitions where petid=%i",atoi(sep->argplus[1])), errbuf)) {
and drop the result altogether, since i dont think DELETE calls return a result set at all - and RunQuery should detect this as an error condition (result set requested on query that doesnt return one) and return false, and set the errbuf accordingly.
Code:
strcpy(errbuf, "DBcore::RunQuery: No Result");
I think affected_rows gets set on delete queries though, i might be wrong there however, but if it does that'd be the response from the mysql server you'd want to look at to find out if the query worked.
Another note, it'd be good to have:
Code:
if (database.RunQuery(query, MakeAnyLenString(...), ...) {
...
safe_delete_array(query);
} else {
safe_delete_array(query);
}
so you dont memleak the query variable. =)