From 3a4207b863954249e1436eccb69e4d865b75970c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 30 Jan 2019 19:32:54 +0100 Subject: [PATCH] Fix dumb bug in HashTable::clear(). We forgot to clear the m_buckets pointer. This meant that multiple calls to clear() would cause trouble. --- AK/HashTable.h | 5 ++++- Kernel/Ext2FileSystem.cpp | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AK/HashTable.h b/AK/HashTable.h index fef82c4692..88439445d5 100644 --- a/AK/HashTable.h +++ b/AK/HashTable.h @@ -301,7 +301,10 @@ void HashTable::rehash(unsigned new_capacity) template void HashTable::clear() { - delete [] m_buckets; + if (m_buckets) { + delete [] m_buckets; + m_buckets = nullptr; + } m_capacity = 0; m_size = 0; } diff --git a/Kernel/Ext2FileSystem.cpp b/Kernel/Ext2FileSystem.cpp index 0ebac398f6..e24b7a573e 100644 --- a/Kernel/Ext2FileSystem.cpp +++ b/Kernel/Ext2FileSystem.cpp @@ -373,9 +373,6 @@ void Ext2FSInode::flush_metadata() // Unless we're about to go away permanently, invalidate the lookup cache. if (m_raw_inode.i_links_count != 0) { LOCKER(m_lock); - // FIXME: Something isn't working right when we hit this code path. - // I've seen crashes inside HashMap::clear() all the way down in DoublyLinkedList::clear(). - // My guess would be a HashTable bug. // FIXME: This invalidation is way too hardcore. It's sad to throw away the whole cache. m_lookup_cache.clear(); }