test: netns: Guard against "double free" when failing to setup netns

When used as a context manager, __exit__ will be called even though
__enter__ might throw an exception half way through. So there is no
guarantee that the instance is on the cleanup list when we get to
stop().
This commit is contained in:
Tobias Waldekranz
2024-11-04 14:42:31 +01:00
parent 2a6e4402f8
commit a4a4a49eae
+2 -1
View File
@@ -87,7 +87,8 @@ class IsolatedMacVlans:
def stop(self):
self.sleeper.kill()
self.sleeper.wait()
self.Instances.remove(self)
if self in self.Instances:
self.Instances.remove(self)
time.sleep(0.5)
def __enter__(self):