Fixes a crash caused by invalid skill ID (#4935)

* Fixes #4934.
* Fixes a potential crash when using atcommand useskill.
Thanks to @Stingor and @CairoLee!
This commit is contained in:
CairoLee
2020-05-20 21:22:53 +08:00
committed by GitHub
parent c3dda07180
commit bf4b41bd66
2 changed files with 14 additions and 0 deletions

View File

@@ -1558,6 +1558,9 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
int inf = skill_get_inf(skill_id);
std::shared_ptr<s_skill_db> skill = skill_db.find(skill_id);
if (!skill)
return 0;
// temp: used to signal combo-skills right now.
if (sc && sc->data[SC_COMBO] &&
skill_is_combo(skill_id) &&
@@ -2035,6 +2038,9 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
if (sc && !sc->count)
sc = NULL;
if (!skill_db.find(skill_id))
return 0;
if( sd ) {
if( skill_isNotOk(skill_id, sd) || !skill_check_condition_castbegin(sd, skill_id, skill_lv) )
return 0;