From 6a03890e41b8ea525a6c4c87db2fca1509db0b47 Mon Sep 17 00:00:00 2001
From: Thomas Goyne <plorkyeran@aegisub.org>
Date: Sat, 1 Feb 2014 20:57:00 -0800
Subject: [PATCH] Make deleterange not do totally incorrect things

---
 aegisub/src/auto4_lua_assfile.cpp | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/aegisub/src/auto4_lua_assfile.cpp b/aegisub/src/auto4_lua_assfile.cpp
index f9f2570f2..7f18265bf 100644
--- a/aegisub/src/auto4_lua_assfile.cpp
+++ b/aegisub/src/auto4_lua_assfile.cpp
@@ -438,13 +438,12 @@ namespace Automation4 {
 
 		if (a >= b) return;
 
-		for (; b < lines.size(); ++a, ++b) {
-			modification_type |= modification_mask(lines[a]);
-			lines_to_delete.emplace_back(lines[a]);
-			lines[a] = lines[b];
+		for (size_t i = a; i < b; ++i) {
+			modification_type |= modification_mask(lines[i]);
+			lines_to_delete.emplace_back(lines[i]);
 		}
 
-		lines.erase(lines.begin() + a, lines.end());
+		lines.erase(lines.begin() + a, lines.begin() + b);
 	}
 
 	void LuaAssFile::ObjectAppend(lua_State *L)
-- 
GitLab