Преглед на файлове

Fix dumb bug in HashTable::clear().

We forgot to clear the m_buckets pointer. This meant that multiple calls to
clear() would cause trouble.
Andreas Kling преди 6 години
родител
ревизия
3a4207b863
променени са 2 файла, в които са добавени 4 реда и са изтрити 4 реда
  1. 4 1
      AK/HashTable.h
  2. 0 3
      Kernel/Ext2FileSystem.cpp

+ 4 - 1
AK/HashTable.h

@@ -301,7 +301,10 @@ void HashTable<T, TraitsForT>::rehash(unsigned new_capacity)
 template<typename T, typename TraitsForT>
 template<typename T, typename TraitsForT>
 void HashTable<T, TraitsForT>::clear()
 void HashTable<T, TraitsForT>::clear()
 {
 {
-    delete [] m_buckets;
+    if (m_buckets) {
+        delete [] m_buckets;
+        m_buckets = nullptr;
+    }
     m_capacity = 0;
     m_capacity = 0;
     m_size = 0;
     m_size = 0;
 }
 }

+ 0 - 3
Kernel/Ext2FileSystem.cpp

@@ -373,9 +373,6 @@ void Ext2FSInode::flush_metadata()
         // Unless we're about to go away permanently, invalidate the lookup cache.
         // Unless we're about to go away permanently, invalidate the lookup cache.
         if (m_raw_inode.i_links_count != 0) {
         if (m_raw_inode.i_links_count != 0) {
             LOCKER(m_lock);
             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.
             // FIXME: This invalidation is way too hardcore. It's sad to throw away the whole cache.
             m_lookup_cache.clear();
             m_lookup_cache.clear();
         }
         }