Introduction
Introduction Statistics Contact Development Disclaimer Help
slackline: fix reallocation memory issue - lchat - A line oriented chat front e…
git clone git://git.suckless.org/lchat
Log
Files
Refs
README
---
commit d671b2273e2283df46dd940dc7ce6a1a3476f9eb
parent dbc8751dc6c034967d2b3133a58a627834992e8c
Author: Petr VanÄ›k <[email protected]>
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:
M slackline.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;
}
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.