* lib/di-set.c (di_set_free): Avoid ino_map_free() when dis->ino_map
is NULL. Bug introduced in commit
3703dbbe88dd.
* tests/test-di-set.c: Add di_set_free() right after di_set_alloc()
as a test.
+2019-04-18 Bernhard Voelker <mail@bernhard-voelker.de>
+
+ di-set: allow free with 'ino_map' being NULL.
+ * lib/di-set.c (di_set_free): Avoid ino_map_free() when dis->ino_map
+ is NULL. Bug introduced in commit 3703dbbe88dd.
+ * tests/test-di-set.c: Add di_set_free() right after di_set_alloc()
+ as a test.
+
2019-04-14 Paul Eggert <eggert@cs.ucla.edu>
* lib/str-two-way.h: Fix comment typo.
di_set_free (struct di_set *dis)
{
hash_free (dis->dev_map);
- ino_map_free (dis->ino_map);
+ if (dis->ino_map)
+ ino_map_free (dis->ino_map);
free (dis->probe);
free (dis);
}
{
struct di_set *dis = di_set_alloc ();
ASSERT (dis);
+ di_set_free (dis); /* free with dis->ino_map still being NULL */
+ dis = di_set_alloc ();
+ ASSERT (dis);
ASSERT (di_set_lookup (dis, 2, 5) == 0); /* initial lookup fails */
ASSERT (di_set_insert (dis, 2, 5) == 1); /* first insertion succeeds */