From 6d4b943479200b1b5e14f4403adeaa0a421f5567 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sun, 29 Aug 2010 14:50:20 -0700 Subject: Potential fix for a crash in llfontgl --- linden/indra/llrender/llfontgl.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/llrender/llfontgl.cpp b/linden/indra/llrender/llfontgl.cpp index beecb6b..5d3d6a7 100644 --- a/linden/indra/llrender/llfontgl.cpp +++ b/linden/indra/llrender/llfontgl.cpp @@ -725,17 +725,18 @@ F32 LLFontGL::getWidthF32(const std::string& utf8text, const S32 begin_offset, c F32 LLFontGL::getWidthF32(const llwchar* wchars, const S32 begin_offset, const S32 max_chars, BOOL use_embedded) const { + if (!wchars || !wchars[0] || max_chars == 0) + { + return 0; + } + const S32 LAST_CHARACTER = LLFont::LAST_CHAR_FULL; F32 cur_x = 0; const S32 max_index = begin_offset + max_chars; - for (S32 i = begin_offset; i < max_index; i++) + for (S32 i = begin_offset; i < max_index && wchars[i] != 0; i++) { - const llwchar wch = wchars[i]; - if (wch == 0) - { - break; // done - } + llwchar wch = wchars[i]; const embedded_data_t* ext_data = use_embedded ? getEmbeddedCharData(wch) : NULL; if (ext_data) { @@ -764,6 +765,11 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars, const S32 begin_offset, const S cur_x = (F32)llfloor(cur_x + 0.5f); } + if (cur_x == 0) + { + return cur_x; + } + return cur_x / sScaleX; } -- cgit v1.1