Skip to content

Commit

Permalink
Discard MRU entries with invalid encodings
Browse files Browse the repository at this point in the history
Instead of crashing Aegisub's startup entirely. See e.g. #267.
  • Loading branch information
arch1t3cht committed Jan 5, 2025
1 parent 6de9ee2 commit 41e12ec
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions libaegisub/common/mru.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,15 @@ void MRUManager::Load(std::string_view key, const json::Array& array) {

try {
mru[idx].reserve(array.size());
for (std::string const& str : array)
mru[idx].push_back(str);
for (std::string const& str : array) {
try {
mru[idx].push_back(str);
} catch (const std::exception &e) {
// Discard values with invalid (non-UTF-8) encodings.
// The exceptions thrown by the std::filesystem::path constructur are implementation-defined
// so we have to do a catchall.
}
}
}
catch (json::Exception const&) {
// Out of date MRU file; just discard the data and skip it
Expand Down

0 comments on commit 41e12ec

Please sign in to comment.