mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
[Bug Fix] Fix use-after-free corruption with some DB calls (#1335)
This commit is contained in:
committed by
GitHub
parent
c063d9512e
commit
4358e24dab
+12
-8
@@ -870,36 +870,40 @@ void Database::GetCharName(uint32 char_id, char* name) {
|
||||
}
|
||||
}
|
||||
|
||||
const char* Database::GetCharNameByID(uint32 char_id) {
|
||||
std::string Database::GetCharNameByID(uint32 char_id) {
|
||||
std::string query = fmt::format("SELECT `name` FROM `character_data` WHERE id = {}", char_id);
|
||||
auto results = QueryDatabase(query);
|
||||
std::string res;
|
||||
|
||||
if (!results.Success()) {
|
||||
return "";
|
||||
return res;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0) {
|
||||
return "";
|
||||
return res;
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
return row[0];
|
||||
res = row[0];
|
||||
return res;
|
||||
}
|
||||
|
||||
const char* Database::GetNPCNameByID(uint32 npc_id) {
|
||||
std::string Database::GetNPCNameByID(uint32 npc_id) {
|
||||
std::string query = fmt::format("SELECT `name` FROM `npc_types` WHERE id = {}", npc_id);
|
||||
auto results = QueryDatabase(query);
|
||||
std::string res;
|
||||
|
||||
if (!results.Success()) {
|
||||
return "";
|
||||
return res;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0) {
|
||||
return "";
|
||||
return res;
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
return row[0];
|
||||
res = row[0];
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Database::LoadVariables() {
|
||||
|
||||
+2
-2
@@ -138,8 +138,8 @@ public:
|
||||
|
||||
void GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID = 0);
|
||||
void GetCharName(uint32 char_id, char* name);
|
||||
const char *GetCharNameByID(uint32 char_id);
|
||||
const char *GetNPCNameByID(uint32 npc_id);
|
||||
std::string GetCharNameByID(uint32 char_id);
|
||||
std::string GetNPCNameByID(uint32 npc_id);
|
||||
void LoginIP(uint32 AccountID, const char* LoginIP);
|
||||
|
||||
/* Instancing */
|
||||
|
||||
Reference in New Issue
Block a user