浏览代码

Fix possible crash in script_text_editor.cpp

rune-scape 1 年之前
父节点
当前提交
a938359cd3
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      editor/plugins/script_text_editor.cpp

+ 4 - 1
editor/plugins/script_text_editor.cpp

@@ -500,11 +500,14 @@ void ScriptTextEditor::_validate_script() {
 	safe_lines.clear();
 
 	if (!script->get_language()->validate(text, script->get_path(), &fnc, &errors, &warnings, &safe_lines)) {
-		for (List<ScriptLanguage::ScriptError>::Element *E = errors.front(); E; E = E->next()) {
+		List<ScriptLanguage::ScriptError>::Element *E = errors.front();
+		while (E) {
+			List<ScriptLanguage::ScriptError>::Element *next_E = E->next();
 			if ((E->get().path.is_empty() && !script->get_path().is_empty()) || E->get().path != script->get_path()) {
 				depended_errors[E->get().path].push_back(E->get());
 				E->erase();
 			}
+			E = next_E;
 		}
 
 		if (errors.size() > 0) {