]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix MemPools::GetInstance() potential destruct sequence
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 28 Mar 2016 22:14:41 +0000 (11:14 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 28 Mar 2016 22:14:41 +0000 (11:14 +1300)
src/mem/Pool.cc

index b81d561532ca7a77b655c8682b56f58b666eebd8..4db5fe78412e282eefde35bf8c1a0ad1560f66e0 100644 (file)
@@ -32,8 +32,11 @@ MemPools::GetInstance()
     /* Must use this idiom, as we can be double-initialised
      * if we are called during static initialisations.
      */
-    static MemPools Instance;
-    return Instance;
+    static MemPools *Instance = nullptr;
+    if (!Instance) {
+        Instance = new MemPools;
+    }
+    return *Instance;
 }
 
 MemPoolIterator *