Skip to content

Commit

Permalink
hash: fix crash on element deletion
Browse files Browse the repository at this point in the history
Fixes: neomutt#2969

When NeoMutt frees a ConfigSubset, it iterates through the set passing
the name (key) of each item to mutt_hash_delete().

Unfortunately, passing the key name from `struct Inheritance` doesn't
work.  The HashTable uses the name after deleting the item to check for
duplicate items.
  • Loading branch information
flatcap committed Jun 18, 2021
1 parent 35f8965 commit b6aa30d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mutt/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,10 @@ void mutt_hash_delete(struct HashTable *table, const char *strkey, const void *d
if (!table || !strkey)
return;
union HashKey key;
key.strkey = strkey;
// Copy the key because union_hash_delete() may use it after the HashElem is freed.
key.strkey = mutt_str_dup(strkey);
union_hash_delete(table, key, data);
FREE(&key.strkey);
}

/**
Expand Down

0 comments on commit b6aa30d

Please sign in to comment.