From 9970f05ec8e3fcac0060cdd4de05fde48b0526ef Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 17 Mar 2018 20:48:52 +0100 Subject: [PATCH] DolphinQt2: Fix issues with MoIterator Before this, DolphinQt2 would crash at boot with an assertion error when using a Windows debug build, at least if the Dolphin GUI language was set to English. --- Source/Core/DolphinQt2/Translation.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinQt2/Translation.cpp b/Source/Core/DolphinQt2/Translation.cpp index 8b6a6615d0..e22b4dbb6b 100644 --- a/Source/Core/DolphinQt2/Translation.cpp +++ b/Source/Core/DolphinQt2/Translation.cpp @@ -53,7 +53,10 @@ public: // boost::iterator_facade library, which nicely separates out application logic from // iterator-concept logic. void advance(difference_type n) { m_index += n; } - difference_type distance_to(const MoIterator& other) const { return other.m_index - m_index; } + difference_type distance_to(const MoIterator& other) const + { + return static_cast(other.m_index) - m_index; + } reference dereference() const { u32 offset = ReadU32(&m_data[m_table_offset + m_index * 8 + 4]); @@ -177,7 +180,7 @@ public: auto iter = std::lower_bound(begin, end, original_string, [](const char* a, const char* b) { return strcmp(a, b) < 0; }); - if (strcmp(*iter, original_string) != 0) + if (iter == end || strcmp(*iter, original_string) != 0) return original_string; u32 offset = ReadU32(&m_data[m_offset_translation_table + std::distance(begin, iter) * 8 + 4]);