Skip to content

Commit

Permalink
pound: zrealloc left half of split line when newline is inserted, too.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivop committed Sep 11, 2024
1 parent 1ec0dfc commit 12e8f29
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/pound.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ void editorInsertNewline(void) {
if (!editorInsertRow(E.cy + 1, &row->chars[E.cx], row->size - E.cx))
goto failed;
row = &E.row[E.cy]; // reassign because zrealloc might have moved it
row->size = E.cx; // xxx: zrealloc to free memory?
row->size = E.cx;
row->chars = zrealloc(row->chars, row->size + 1);
row->chars[row->size] = '\0';
}
E.cy++;
Expand Down

0 comments on commit 12e8f29

Please sign in to comment.