From 6ac2782ffdbdc5d28b9ac36106df24b5156f3cbf Mon Sep 17 00:00:00 2001 From: csaftoiu Date: Tue, 19 Nov 2013 19:21:55 -0500 Subject: [PATCH] Infinite loop bug This caused an infinite loop when I had a string along the lines of something like " Next ". This is the simple fix. --- cocos2d/label_nodes/CCLabelTTF.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cocos2d/label_nodes/CCLabelTTF.js b/cocos2d/label_nodes/CCLabelTTF.js index e21c94f637..09ab551238 100644 --- a/cocos2d/label_nodes/CCLabelTTF.js +++ b/cocos2d/label_nodes/CCLabelTTF.js @@ -682,6 +682,9 @@ cc.LabelTTF = cc.Sprite.extend(/** @lends cc.LabelTTF# */{ break; } } while (tempLineWidth > locDimensionsWidth); + if (cutoff === -1) { + break; + } var newline = strings[i].substr(cutoff + 1); strings.splice(i + 1, 0, newline); strings[i] = str;