fix: reassign internal buffer on realloc - webdump - HTML to plain-text converter for webpages
HTML git clone git://git.codemadness.org/webdump
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 5b615707234222a1ecb7c7c637c629d4f45116ff
DIR parent c455f534c9eaf07f1c1304e74edc245fba57af46
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Wed, 11 Mar 2026 00:59:58 +0100
fix: reassign internal buffer on realloc
This could point to an old buffer in a different memory region.
(realloc does not neccesarily allocate in a continous memory area).
Found by Clang ASAN
Diffstat:
M webdump.c | 3 +++
1 file changed, 3 insertions(+), 0 deletions(-)
---
DIR diff --git a/webdump.c b/webdump.c
@@ -1557,6 +1557,9 @@ incnode(void)
memset(&nodes[ncapnodes], 0, sizeof(*nodes) * NODE_CAP_INC);
memset(&nodes_links[ncapnodes], 0, sizeof(*nodes_links) * NODE_CAP_INC);
+ for (i = 0; i < ncapnodes; i++)
+ nodes[i].tag.name = nodes[i].tagname; /* assign to use fixed-size buffer */
+
for (i = ncapnodes; i < ncapnodes + NODE_CAP_INC; i++) {
nodes[i].tag.displaytype = DisplayInline;
nodes[i].tag.name = nodes[i].tagname; /* assign to use fixed-size buffer */