From cbb1055218a67d5af8d559fe72c600283b1429f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Thu, 31 Jan 2019 11:31:06 +0100 Subject: [PATCH] [escher] Fix TextField::ContentView::setEditing --- escher/src/text_field.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/escher/src/text_field.cpp b/escher/src/text_field.cpp index 555e51c99..eab7e828f 100644 --- a/escher/src/text_field.cpp +++ b/escher/src/text_field.cpp @@ -90,9 +90,12 @@ void TextField::ContentView::setEditing(bool isEditing, bool reinitDrafBuffer) { } void TextField::ContentView::reinitDraftTextBuffer() { - setCursorLocation(m_draftTextBuffer); + /* We first need to clear the buffer, otherwise setCursorLocation might do + * various operations on a buffer with maybe non-initialized content, such as + * stringSize, etc. Those operation might be perilous on non-UTF8 content. */ m_draftTextBuffer[0] = 0; m_currentDraftTextLength = 0; + setCursorLocation(m_draftTextBuffer); } bool TextField::ContentView::insertTextAtLocation(const char * text, const char * location) {