]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
fix None pointers in LRU cache sentinel
authorBob Halley <halley@dnspython.org>
Sat, 23 May 2020 17:32:54 +0000 (10:32 -0700)
committerBob Halley <halley@dnspython.org>
Sat, 23 May 2020 17:32:54 +0000 (10:32 -0700)
dns/resolver.py

index 4339a06b39acd2cb03c768b2ec7c09c1448db683..089021d3d390972a9b1880bda40959dfcc0929f9 100644 (file)
@@ -407,6 +407,8 @@ class LRUCache(object):
         self.data = {}
         self.set_max_size(max_size)
         self.sentinel = LRUCacheNode(None, None)
+        self.sentinel.prev = self.sentinel
+        self.sentinel.next = self.sentinel
         self.lock = _threading.Lock()
 
     def set_max_size(self, max_size):
@@ -480,8 +482,7 @@ class LRUCache(object):
                 node = self.sentinel.next
                 while node != self.sentinel:
                     next = node.next
-                    node.prev = None
-                    node.next = None
+                    node.unlink()
                     node = next
                 self.data = {}