[hackers] [lchat] slackline: fix reallocation memory issue || Petr Vaněk
commit d671b2273e2283df46dd940dc7ce6a1a3476f9eb
Author: Petr Vaněk <arkamar_AT_atlas.cz>
AuthorDate: Mon Sep 26 16:27:12 2022 +0200
Commit: Jan Klemkow <j.klemkow_AT_wemelug.de>
CommitDate: Sun Oct 2 03:47:29 2022 +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.
diff --git a/slackline.c b/slackline.c
index d93fe7a..bc4dfe9 100644
--- a/slackline.c
+++ b/slackline.c
_AT_@ -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;
}
Received on Sun Oct 02 2022 - 03:48:22 CEST
This archive was generated by hypermail 2.3.0
: Sun Oct 02 2022 - 03:48:39 CEST