]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
author: Alex Rousskov <rousskov@measurement-factory.com>
authorChristos Tsantilas <chtsanti@users.sourceforge.net>
Fri, 9 May 2014 15:19:40 +0000 (18:19 +0300)
committerChristos Tsantilas <chtsanti@users.sourceforge.net>
Fri, 9 May 2014 15:19:40 +0000 (18:19 +0300)
Avoid on-exit crashes when adaptation is enabled.

After trunk r13269 (Vector refactor) destroyed vector objects still have
positive item counts. This exposes use-after-delete bugs. In this particular
case, global adaptation rule/group/service arrays are destructed by global
destruction sequence first and then again by Adaptation::*::TheConfig objects
destructors.

This change avoiding static destruction order dependencies by storing those
global adaptation arrays on heap.

src/adaptation/AccessRule.cc
src/adaptation/Service.cc
src/adaptation/ServiceGroups.cc

index 8331656aa1581bcca3475cd2525c0c68c1683098..7e2845a76848b521305e2c5a75f3a1ed23659f62 100644 (file)
@@ -51,8 +51,8 @@ Adaptation::AccessRule::group()
 Adaptation::AccessRules &
 Adaptation::AllRules()
 {
-    static AccessRules TheRules;
-    return TheRules;
+    static AccessRules *TheRules = new AccessRules;
+    return *TheRules;
 }
 
 // TODO: make AccessRules::find work
index 10f1e642e81c54e9d14a8e00fbcc73eb29057c81..7160ebe67320480158c852d4ef585bb08892af9d 100644 (file)
@@ -54,8 +54,8 @@ Adaptation::Service::wants(const ServiceFilter &filter) const
 Adaptation::Services &
 Adaptation::AllServices()
 {
-    static Services TheServices;
-    return TheServices;
+    static Services *TheServices = new Services;
+    return *TheServices;
 }
 
 Adaptation::ServicePointer
index 28e7d83763e20b868e9ec3f3b9a8c49b593bbdf5..23269621166401c21b4ab3a49740f64e46f396ec 100644 (file)
@@ -315,8 +315,8 @@ Adaptation::ServicePlan::print(std::ostream &os) const
 Adaptation::Groups &
 Adaptation::AllGroups()
 {
-    static Groups TheGroups;
-    return TheGroups;
+    static Groups *TheGroups = new Groups;
+    return *TheGroups;
 }
 
 Adaptation::ServiceGroupPointer