diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index 45adbfacd..2870feba1 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -1678,9 +1678,12 @@ void CObjectListWindow::trimTextIfTooWide(std::string & text, bool preserveCount { auto posBrace = text.find_last_of("("); auto posClosing = text.find_last_of(")"); - std::string objCount = text.substr(posBrace, posClosing - posBrace) + ')'; - suffix += " "; - suffix += objCount; + if (posBrace != std::string::npos && posClosing != std::string::npos && posBrace < posClosing) + { + std::string objCount = text.substr(posBrace, posClosing - posBrace) + ')'; + suffix += " "; + suffix += objCount; + } } const auto & font = ENGINE->renderHandler().loadFont(FONT_SMALL);