Fix UB, thanks Router and Clang for the heads up

This commit is contained in:
Lirusaito
2019-06-29 21:23:07 -04:00
parent 128d30bd4b
commit 8fef329437

View File

@@ -4566,7 +4566,9 @@ void LLTextEditor::appendAndHighlightTextImpl(const std::string& new_text, S32 h
insertStringNoUndo(cur_length, wide_text);
LLStyleSP sp(new LLStyle(*stylep));
sp->setColor(piece["color"]);
LLTextSegmentPtr segmentp = new LLTextSegment(sp, cur_length, cur_length += wide_text.size());
auto wide_size = wide_text.size();
LLTextSegmentPtr segmentp = new LLTextSegment(sp, cur_length, cur_length + wide_size);
cur_length += wide_size;
if (underline_on_hover) segmentp->setUnderlineOnHover(true);
mSegments.push_back(segmentp);
}