ImFontGlyphRangesBuilder: Fixed unnecessarily over-sized buffer, which incidentally was also not fully cleared. Fixed edge case overflow when adding character 0xFFFF. (#2568)

This commit is contained in:
omar
2019-05-21 12:45:27 +02:00
parent 882d2c3aea
commit 34b881eb12
3 changed files with 11 additions and 7 deletions

View File

@ -2391,11 +2391,12 @@ void ImFontGlyphRangesBuilder::AddRanges(const ImWchar* ranges)
void ImFontGlyphRangesBuilder::BuildRanges(ImVector<ImWchar>* out_ranges)
{
for (int n = 0; n < 0x10000; n++)
int max_codepoint = 0x10000;
for (int n = 0; n < max_codepoint; n++)
if (GetBit(n))
{
out_ranges->push_back((ImWchar)n);
while (n < 0x10000 && GetBit(n + 1))
while (n < max_codepoint - 1 && GetBit(n + 1))
n++;
out_ranges->push_back((ImWchar)n);
}