From 54cd55523bd24161d3596928a4658737243001cd Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 11 Jul 2018 17:36:39 +0300 Subject: [PATCH] Fix crash in markdown preprocessing. --- Telegram/SourceFiles/ui/widgets/input_fields.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/ui/widgets/input_fields.cpp b/Telegram/SourceFiles/ui/widgets/input_fields.cpp index cd6e4f547..c1c4b807a 100644 --- a/Telegram/SourceFiles/ui/widgets/input_fields.cpp +++ b/Telegram/SourceFiles/ui/widgets/input_fields.cpp @@ -426,10 +426,11 @@ private: int newlinePosition(const QString &text, int offset) const { const auto length = text.size(); if (offset < length) { - auto ch = text.data() + offset; - for (const auto e = ch + length; ch != e; ++ch) { + const auto begin = text.data(); + const auto end = begin + length; + for (auto ch = begin + offset; ch != end; ++ch) { if (IsNewline(*ch)) { - return (ch - text.data()); + return (ch - begin); } } }