Skip to content

Commit

Permalink
fix egc memory error
Browse files Browse the repository at this point in the history
ensure space allocated for null-terminator
  • Loading branch information
adsr committed Dec 18, 2024
1 parent 7487f1b commit 25c3f8b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions termbox2.h
Original file line number Diff line number Diff line change
Expand Up @@ -1778,11 +1778,11 @@ int tb_extend_cell(int x, int y, uint32_t ch) {
if_err_return(rv, cellbuf_get(&global.back, x, y, &cell));
if (cell->nech > 0) { // append to ech
nech = cell->nech + 1;
if_err_return(rv, cell_reserve_ech(cell, nech));
if_err_return(rv, cell_reserve_ech(cell, nech + 1));
cell->ech[nech - 1] = ch;
} else { // make new ech
nech = 2;
if_err_return(rv, cell_reserve_ech(cell, nech));
if_err_return(rv, cell_reserve_ech(cell, nech + 1));
cell->ech[0] = cell->ch;
cell->ech[1] = ch;
}
Expand Down

0 comments on commit 25c3f8b

Please sign in to comment.