diff options
author | McCabe Maxsted | 2010-08-29 14:50:20 -0700 |
---|---|---|
committer | Jacek Antonelli | 2010-09-16 20:39:40 -0500 |
commit | 6d4b943479200b1b5e14f4403adeaa0a421f5567 (patch) | |
tree | 72e046da7f217a55b7fe06cc7f60e2ddb5f7a1eb /linden/indra | |
parent | correct capitalization of error message key (diff) | |
download | meta-impy-6d4b943479200b1b5e14f4403adeaa0a421f5567.zip meta-impy-6d4b943479200b1b5e14f4403adeaa0a421f5567.tar.gz meta-impy-6d4b943479200b1b5e14f4403adeaa0a421f5567.tar.bz2 meta-impy-6d4b943479200b1b5e14f4403adeaa0a421f5567.tar.xz |
Potential fix for a crash in llfontgl
Diffstat (limited to 'linden/indra')
-rw-r--r-- | linden/indra/llrender/llfontgl.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
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 | |||
725 | 725 | ||
726 | F32 LLFontGL::getWidthF32(const llwchar* wchars, const S32 begin_offset, const S32 max_chars, BOOL use_embedded) const | 726 | F32 LLFontGL::getWidthF32(const llwchar* wchars, const S32 begin_offset, const S32 max_chars, BOOL use_embedded) const |
727 | { | 727 | { |
728 | if (!wchars || !wchars[0] || max_chars == 0) | ||
729 | { | ||
730 | return 0; | ||
731 | } | ||
732 | |||
728 | const S32 LAST_CHARACTER = LLFont::LAST_CHAR_FULL; | 733 | const S32 LAST_CHARACTER = LLFont::LAST_CHAR_FULL; |
729 | 734 | ||
730 | F32 cur_x = 0; | 735 | F32 cur_x = 0; |
731 | const S32 max_index = begin_offset + max_chars; | 736 | const S32 max_index = begin_offset + max_chars; |
732 | for (S32 i = begin_offset; i < max_index; i++) | 737 | for (S32 i = begin_offset; i < max_index && wchars[i] != 0; i++) |
733 | { | 738 | { |
734 | const llwchar wch = wchars[i]; | 739 | llwchar wch = wchars[i]; |
735 | if (wch == 0) | ||
736 | { | ||
737 | break; // done | ||
738 | } | ||
739 | const embedded_data_t* ext_data = use_embedded ? getEmbeddedCharData(wch) : NULL; | 740 | const embedded_data_t* ext_data = use_embedded ? getEmbeddedCharData(wch) : NULL; |
740 | if (ext_data) | 741 | if (ext_data) |
741 | { | 742 | { |
@@ -764,6 +765,11 @@ F32 LLFontGL::getWidthF32(const llwchar* wchars, const S32 begin_offset, const S | |||
764 | cur_x = (F32)llfloor(cur_x + 0.5f); | 765 | cur_x = (F32)llfloor(cur_x + 0.5f); |
765 | } | 766 | } |
766 | 767 | ||
768 | if (cur_x == 0) | ||
769 | { | ||
770 | return cur_x; | ||
771 | } | ||
772 | |||
767 | return cur_x / sScaleX; | 773 | return cur_x / sScaleX; |
768 | } | 774 | } |
769 | 775 | ||