Переглянути джерело

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!
Aleos 3 роки тому
батько
коміт
0f4f612878
1 змінених файлів з 6 додано та 3 видалено
  1. 6 3
      src/map/script.cpp

+ 6 - 3
src/map/script.cpp

@@ -12001,13 +12001,16 @@ 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;
 
-		if (status_db.hasSCF(sc, SCF_NOCLEARBUFF))
+		struct status_change_entry *sce = sc->data[type];
+
+		if (sce == nullptr)
 			return SCRIPT_CMD_SUCCESS;
 
-		struct status_change_entry *sce = sc ? sc->data[type] : NULL;
+		if (status_db.hasSCF(sc, SCF_NOCLEARBUFF))
+			return SCRIPT_CMD_SUCCESS;
 
 		//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;