lchat

A line oriented chat front end for ii.
git clone git://git.suckless.org/lchat
Log | Files | Refs | README

commit d671b2273e2283df46dd940dc7ce6a1a3476f9eb
parent dbc8751dc6c034967d2b3133a58a627834992e8c
Author: Petr Vaněk <arkamar@atlas.cz>
Date:   Mon, 26 Sep 2022 16:27:12 +0200

slackline: fix reallocation memory issue

It is necessary to update sl->ptr and sl->last pointers appropriately
after reallocation otherwise backspacing or deleting can work in wrong
memory area.

Diffstat:
Mslackline.c | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/slackline.c b/slackline.c @@ -239,6 +239,8 @@ compose: if ((nbuf = realloc(sl->buf, sl->bufsize * 2)) == NULL) return -1; + sl->ptr = nbuf + (sl->ptr - sl->buf); + sl->last = nbuf + (sl->last - sl->buf); sl->buf = nbuf; sl->bufsize *= 2; }