diff lib/fts.c @ 19683:c4547aaaa88f

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
author Pádraig Brady <P@draigBrady.com>
date Sun, 13 May 2018 18:42:37 -0700
parents 359b539b5677
children 9c4bd940d721
line wrap: on
line diff
--- a/lib/fts.c	Mon May 21 02:42:01 2018 +0200
+++ b/lib/fts.c	Sun May 13 18:42:37 2018 -0700
@@ -546,6 +546,7 @@
                 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;