From b62cbc1cf3df4c8a5b3e5998e4f5fd5d2f0e7b21 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Wed, 11 Mar 2015 02:20:40 +0100 Subject: [PATCH] fix: UB due to pos=57, begin=58 (first char finded) infinite cycle => *chp : crash in text_editor --- source/gui/widgets/skeletons/text_editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index f8ffa7f0..e5125c9c 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -2528,7 +2528,7 @@ namespace nana{ namespace widgets //The number of new lines minus one 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') lines.emplace_back(0, 0);