Michał Górny <[email protected]> reported that patch was running out of
FDs and that the `deep-directories` test was failing. This turns out
to be because `hash_insert` isn't called at all with `-DNDEBUG` because
`insert_cached_dirfd` only calls it in one case inside of an `assert`.

See https://github.com/conda-forge/patch-feedstock/issues/11.

This regressed in 025a54b789bd88ed15430f8633514e296826983e.

* src/safe.c (insert_cached_dirfd): Don't use 'assert' for 'hash_insert'
  call with side-effects.
---
 src/safe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/safe.c b/src/safe.c
index 1085042..5c32310 100644
--- a/src/safe.c
+++ b/src/safe.c
@@ -183,7 +183,8 @@ static void insert_cached_dirfd (struct cached_dirfd 
*entry, int keepfd)
 
   /* Only insert if the parent still exists. */
   if (! list_empty (&entry->children_link))
-    assert (hash_insert (cached_dirfds, entry) == entry);
+    if (hash_insert (cached_dirfds, entry) != entry)
+      xalloc_die ();
 }
 
 static void invalidate_cached_dirfd (int dirfd, const char *name)

base-commit: 1da6bf84db2ed0be88ccb47139256e48243a75f0
-- 
2.48.1


Reply via email to