From 0f4f6128788db0680c57469e0fac2a042ee3985a Mon Sep 17 00:00:00 2001 From: Aleos Date: Fri, 11 Mar 2022 11:19:42 -0500 Subject: [PATCH] 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! --- src/map/script.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/map/script.cpp b/src/map/script.cpp index 7a82c8e56b..3ac1fd278e 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -12001,14 +12001,17 @@ BUILDIN_FUNC(sc_end) if (type >= SC_NONE && type < SC_MAX) { 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; if (status_db.hasSCF(sc, SCF_NOCLEARBUFF)) 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. sce->val1 = sce->val2 = sce->val3 = sce->val4 = 0; status_change_end(bl, (sc_type)type, INVALID_TIMER);