diff --git a/cocos/ui/UIRichText.cpp b/cocos/ui/UIRichText.cpp index 886a42ad72..868bf7f806 100644 --- a/cocos/ui/UIRichText.cpp +++ b/cocos/ui/UIRichText.cpp @@ -283,6 +283,8 @@ void RichText::handleTextRenderer(const std::string& text, const std::string& fo std::string curText = text; size_t stringLength = StringUtils::getCharacterCountInUTF8String(text); int leftLength = stringLength * (1.0f - overstepPercent); + //The minimum cut length is 1, otherwise will cause the infinite loop. + if (0 == leftLength) leftLength = 1; std::string leftWords = Helper::getSubStringOfUTF8String(curText,0,leftLength); std::string cutWords = Helper::getSubStringOfUTF8String(curText, leftLength, stringLength - leftLength); if (leftLength > 0)