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
1 changed files with 2 additions and 2 deletions

View File

@ -1070,10 +1070,10 @@ static void editorProcessKeypress(lua_State* L) {
switch(c) {
case ENTER:
{
erow* oldrow = &E.row[E.rowoff + E.cy];
editorInsertNewline();
/* 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(' ');
}
break;