From 792d93df1c889c61a0cfc4e480d97ca0727a0a58 Mon Sep 17 00:00:00 2001
From: Thomas Goyne <plorkyeran@aegisub.org>
Date: Sat, 22 Nov 2014 13:21:58 -0800
Subject: [PATCH] Fix crash on a certain kind of malformed shift times history
 file

---
 src/dialog_shift_times.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/dialog_shift_times.cpp b/src/dialog_shift_times.cpp
index dc4f183de..268e307ea 100644
--- a/src/dialog_shift_times.cpp
+++ b/src/dialog_shift_times.cpp
@@ -109,8 +109,10 @@ static wxString get_history_string(json::Object &obj) {
 	int64_t sel_mode = obj["mode"];
 	if (sel_mode == 0)
 		lines = _("all");
-	else if (sel_mode == 2)
-		lines = fmt_tl("from %d onward", (int64_t)static_cast<json::Object&>(sel.front())["start"]);
+	else if (sel_mode == 2) {
+		if (!sel.empty())
+			lines = fmt_tl("from %d onward", (int64_t)static_cast<json::Object&>(sel.front())["start"]);
+	}
 	else {
 		lines += _("sel ");
 		for (auto it = sel.begin(); it != sel.end(); ++it) {
-- 
GitLab