From 9b4ce2dbe2353cbbfe98f2819d0f3074d54e6b55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= jaakko.keranen@iki.fi
Date: Fri, 30 Jul 2021 08:29:31 +0300
Subject: [PATCH 1/1] InputWidget: Fixed undefined behavior when inserting a
newline
src/ui/inputwidget.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index c9779ff0..50b12d1f 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -969,11 +969,11 @@ static void textOfLinesWasChanged_InputWidget_(iInputWidget *d, iRangei lineRang
static void insertRange_InputWidget_(iInputWidget *d, iRangecc range) {
iRangecc nextRange = { range.end, range.end };
const int firstModified = d->cursor.y;
/* If there's a newline, we'll need to break and begin a new line. */
const char *newline = iStrStrN(range.start, "\n", size_Range(&range));
if (newline) {
nextRange = (iRangecc){ newline + 1, range.end };
nextRange = (iRangecc){ iMin(newline + 1, range.end), range.end };
range.end = newline;
}
iInputLine *line = cursorLine_InputWidget_(d);
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).