Fixes a crash with script command sc_end (#6659)

* Fixes #6657.
* Adds an extra sanity check.
* Moves the database check post the sanity checks for faster processing.
Thanks to @kaninhot004!
This commit is contained in:
Aleos 2022-03-11 11:19:42 -05:00 committed by GitHub
parent 0ca5f450b7
commit 0f4f612878
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12001,14 +12001,17 @@ BUILDIN_FUNC(sc_end)
if (type >= SC_NONE && type < SC_MAX) { if (type >= SC_NONE && type < SC_MAX) {
struct status_change *sc = status_get_sc(bl); struct status_change *sc = status_get_sc(bl);
if (!sc) if (sc == nullptr)
return SCRIPT_CMD_SUCCESS;
struct status_change_entry *sce = sc->data[type];
if (sce == nullptr)
return SCRIPT_CMD_SUCCESS; return SCRIPT_CMD_SUCCESS;
if (status_db.hasSCF(sc, SCF_NOCLEARBUFF)) if (status_db.hasSCF(sc, SCF_NOCLEARBUFF))
return SCRIPT_CMD_SUCCESS; return SCRIPT_CMD_SUCCESS;
struct status_change_entry *sce = sc ? sc->data[type] : NULL;
//This should help status_change_end force disabling the SC in case it has no limit. //This should help status_change_end force disabling the SC in case it has no limit.
sce->val1 = sce->val2 = sce->val3 = sce->val4 = 0; sce->val1 = sce->val2 = sce->val3 = sce->val4 = 0;
status_change_end(bl, (sc_type)type, INVALID_TIMER); status_change_end(bl, (sc_type)type, INVALID_TIMER);