summaryrefslogtreecommitdiff
path: root/lib/fts.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2018-05-13 18:42:37 -0700
committerPádraig Brady <P@draigBrady.com>2018-05-20 23:13:32 -0700
commite90c77eb2608f23caa798a9910d8dc0f9901904a (patch)
tree3ea4c13a2cf2d8c02e79d62b8793929771a11266 /lib/fts.c
parent1193175efd58883626d2b8c454b57a9490538d61 (diff)
downloadgnulib-e90c77eb2608f23caa798a9910d8dc0f9901904a.tar.gz
fts: avoid a memory leak edge case
* lib/fts.c (fts_open): Set an appropriate fts_level so that an immediate fts_close() will free the allocation. * tests/test-fts.c (fts_dealloc): Add a test case which will trigger under valgrind or address sanitizer. Fixes https://bugs.gnu.org/31439
Diffstat (limited to 'lib/fts.c')
-rw-r--r--lib/fts.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/fts.c b/lib/fts.c
index d543510595..1ccc78c116 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -546,6 +546,7 @@ fts_open (char * const *argv,
goto mem3;
sp->fts_cur->fts_link = root;
sp->fts_cur->fts_info = FTS_INIT;
+ sp->fts_cur->fts_level = 1;
if (! setup_dir (sp))
goto mem3;