fix a use-after-free

Introduced Nov 28. Let's see if my intermittent segfaults stop now.
This commit is contained in:
Kartik K. Agaram 2021-12-08 16:47:59 -08:00
parent 71ce944e81
commit 8a70fbd171

View File

@ -1070,10 +1070,10 @@ static void editorProcessKeypress(lua_State* L) {
switch(c) { switch(c) {
case ENTER: case ENTER:
{ {
erow* oldrow = &E.row[E.rowoff + E.cy];
editorInsertNewline(); editorInsertNewline();
/* auto-indent */ /* auto-indent */
for (int x = 0; x < oldrow->size && oldrow->chars[x] == ' '; ++x) erow* prevrow = &E.row[E.rowoff + E.cy - 1];
for (int x = 0; x < prevrow->size && prevrow->chars[x] == ' '; ++x)
editorInsertChar(' '); editorInsertChar(' ');
} }
break; break;