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; }