From 009aeeea2aecbc35399eb74f7f9178e35fdbd754 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 1 Jul 2019 09:17:54 +0200 Subject: Fix alloca'd memory being freed in fstree_from_dir Most code path that use 'extra' allocate it using calloc/malloc/strdup and then converge into a common path that uses free() on extra. This commit removes a stray one that uses alloca for symlink targets, so we don't free() a stack buffer further down in the common path. Bug found using scan-build. Signed-off-by: David Oberhollenzer --- lib/fstree/fstree_from_dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fstree/fstree_from_dir.c b/lib/fstree/fstree_from_dir.c index ea1ebe9..ff9f078 100644 --- a/lib/fstree/fstree_from_dir.c +++ b/lib/fstree/fstree_from_dir.c @@ -78,7 +78,7 @@ static int populate_dir(fstree_t *fs, tree_node_t *root) } if (S_ISLNK(sb.st_mode)) { - extra = alloca(sb.st_size + 1); + extra = calloc(1, sb.st_size + 1); if (extra == NULL) goto fail_rdlink; -- cgit v1.2.3