diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 978bd317e201a3d8bdcddff6446b687bf12eec92..dfe3e9b61ed6884fce565d2d4ea707f81e76a896 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -2512,7 +2512,7 @@ S32	LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin
 	LLUIImagePtr image = mStyle->getImage();
 	if( image.notNull())
 	{
-		num_pixels -= image->getWidth();
+		num_pixels = llmax(0, num_pixels - image->getWidth());
 	}
 
 	// search for newline and if found, truncate there