about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-11-15 19:33:37 +0000
committerEric Wong <e@80x24.org>2022-11-16 09:25:11 +0000
commitdfd859ad96e8d6da4943c770f307d56558588fe7 (patch)
tree3650e003da66ed899f2e8536f2524acf7ba234ec
parentf9f30aad253c6a5d44830a25d82b275a696da3e5 (diff)
downloadmwrap-dfd859ad96e8d6da4943c770f307d56558588fe7.tar.gz
Don't segfault in case we fail to create rculfhash.
-rw-r--r--Mwrap.xs17
1 files changed, 9 insertions, 8 deletions
diff --git a/Mwrap.xs b/Mwrap.xs
index 518edb1..e87fe30 100644
--- a/Mwrap.xs
+++ b/Mwrap.xs
@@ -909,14 +909,15 @@ CODE:
 
         rcu_read_lock();
         t = CMM_LOAD_SHARED(totals);
-        cds_lfht_for_each_entry(t, &iter, l, hnode) {
-                uatomic_set(&l->total, 0);
-                uatomic_set(&l->allocations, 0);
-                uatomic_set(&l->frees, 0);
-                uatomic_set(&l->freed_bytes, 0);
-                uatomic_set(&l->age_total, 0);
-                uatomic_set(&l->max_lifespan, 0);
-        }
+        if (t)
+                cds_lfht_for_each_entry(t, &iter, l, hnode) {
+                        uatomic_set(&l->total, 0);
+                        uatomic_set(&l->allocations, 0);
+                        uatomic_set(&l->frees, 0);
+                        uatomic_set(&l->freed_bytes, 0);
+                        uatomic_set(&l->age_total, 0);
+                        uatomic_set(&l->max_lifespan, 0);
+                }
         rcu_read_unlock();
 
 Devel::Mwrap::SrcLoc