Skip to content

Commit 41e12ec

Browse files
committed
Discard MRU entries with invalid encodings
Instead of crashing Aegisub's startup entirely. See e.g. #267.
1 parent 6de9ee2 commit 41e12ec

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

libaegisub/common/mru.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,15 @@ void MRUManager::Load(std::string_view key, const json::Array& array) {
139139

140140
try {
141141
mru[idx].reserve(array.size());
142-
for (std::string const& str : array)
143-
mru[idx].push_back(str);
142+
for (std::string const& str : array) {
143+
try {
144+
mru[idx].push_back(str);
145+
} catch (const std::exception &e) {
146+
// Discard values with invalid (non-UTF-8) encodings.
147+
// The exceptions thrown by the std::filesystem::path constructur are implementation-defined
148+
// so we have to do a catchall.
149+
}
150+
}
144151
}
145152
catch (json::Exception const&) {
146153
// Out of date MRU file; just discard the data and skip it

0 commit comments

Comments
 (0)