diff --git a/common/database.cpp b/common/database.cpp index 0787f396a..b99eac2ea 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -161,7 +161,7 @@ uint32 Database::CheckLogin(const char* name, const char* password, int16* oStat return 0; } - if(results.RowCount() < 1) + if(results.RowCount() == 0) return 0; auto row = results.begin(); diff --git a/common/mysql_request_row.cpp b/common/mysql_request_row.cpp index ac5fa1592..9491fd1b2 100644 --- a/common/mysql_request_row.cpp +++ b/common/mysql_request_row.cpp @@ -64,6 +64,5 @@ bool MySQLRequestRow::operator!=(const MySQLRequestRow& rhs) char* MySQLRequestRow::operator[](int index) { - return m_MySQLRow[index]; } diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 8e999da54..58a75a261 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -1632,6 +1632,13 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) { int tempid = 0; int counter = 0; + + if(result && mysql_field_count(getMySQL()) <= SPELL_LOAD_FIELD_COUNT) { + _log(SPELLS__LOAD_ERR, "Fatal error loading spells: Spell field count < SPELL_LOAD_FIELD_COUNT(%u)", SPELL_LOAD_FIELD_COUNT); + mysql_free_result(result); + return; + } + while (row = mysql_fetch_row(result)) { tempid = atoi(row[0]); if(tempid >= max_spells) { diff --git a/common/spdat.h b/common/spdat.h index 40f5e658f..2dfc016b4 100644 --- a/common/spdat.h +++ b/common/spdat.h @@ -621,6 +621,8 @@ typedef enum { // number. note that the id field is counted as 0, this way the numbers // here match the numbers given to sep in the loading function net.cpp // +#define SPELL_LOAD_FIELD_COUNT 231 + struct SPDat_Spell_Struct { /* 000 */ int id; // not used