From 815ddff257e44c6fc5d2e78d8103cea9ff19a6d7 Mon Sep 17 00:00:00 2001 From: Romain Geissler Date: Sun, 29 Jun 2025 22:48:17 +0000 Subject: [PATCH] Fixed inconsistencies generated by _md_shrink. This is causing assertion failures in ASSERT_CONSISTENT if an entry used to have a non null identity. Since the new entries will be concentrated at the beginning of the array, we shall "erase" the old entries that are at the end of the array and that won't be used anymore. This is enough to fix the core dump issues found in the testsuite of httpie in Fedora Rawhide. --- CHANGES/1229.bugfix.rst | 1 + multidict/_multilib/hashtable.h | 1 + 2 files changed, 2 insertions(+) create mode 100644 CHANGES/1229.bugfix.rst diff --git a/CHANGES/1229.bugfix.rst b/CHANGES/1229.bugfix.rst new file mode 100644 index 000000000..a8ba7a4a7 --- /dev/null +++ b/CHANGES/1229.bugfix.rst @@ -0,0 +1 @@ +Fixed inconsistencies generated by the C implementation of ``_md_shrink()`` which might later lead to assertion failures and crash -- by :user:`Romain-Geissler-1A`. diff --git a/multidict/_multilib/hashtable.h b/multidict/_multilib/hashtable.h index 0e0a28e50..16b82ded1 100644 --- a/multidict/_multilib/hashtable.h +++ b/multidict/_multilib/hashtable.h @@ -261,6 +261,7 @@ _md_shrink(MultiDictObject *md, bool update) keys->nentries = newnentries; keys->usable += nentries - newnentries; memset(&keys->indices[0], 0xff, ((size_t)1 << keys->log2_index_bytes)); + memset(new_ep, 0, sizeof(entry_t) * (size_t)(nentries - newnentries)); if (htkeys_build_indices(keys, entries, newnentries, update) < 0) { return -1; }