fix: UB due to pos=57, begin=58 (first char finded) infinite cycle => *chp : crash in text_editor

This commit is contained in:
qPCR4vir 2015-03-11 02:20:40 +01:00
parent 24675db26b
commit b62cbc1cf3

View File

@ -2528,7 +2528,7 @@ namespace nana{ namespace widgets
//The number of new lines minus one //The number of new lines minus one
const auto chp_end = text.data() + (begin == text.npos ? text.size() : begin); const auto chp_end = text.data() + (begin == text.npos ? text.size() : begin);
for (auto chp = text.data() + (pos + 2); chp != chp_end; ++chp) for (auto chp = text.data() + (pos + 1); chp != chp_end; ++chp) // + 2
if (*chp == '\n') if (*chp == '\n')
lines.emplace_back(0, 0); lines.emplace_back(0, 0);