ThreadLocalDetail: fix bug just introduced w/ recent change to constexpr-ctor style...
authorSteve O'Brien <steveo@fb.com>
Wed, 2 Dec 2015 17:17:38 +0000 (09:17 -0800)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Wed, 2 Dec 2015 18:20:21 +0000 (10:20 -0800)
Summary: Small, silly bug which is triggered when there are no keys to unregister, invalidating the current size of the structure.

Reviewed By: yzhan

Differential Revision: D2712604

fb-gh-sync-id: f6f031936d8e4e458b49c08714f42cb2eec4c4fe

folly/detail/ThreadLocalDetail.h

index 69d2cabd0d3c1baf73802405fcf5bc645d107e58..1c3f2c72e482be399e9ee73439985dbe7beec712 100644 (file)
@@ -184,8 +184,8 @@ class PthreadKeyUnregister {
 
   ~PthreadKeyUnregister() {
     std::lock_guard<std::mutex> lg(mutex_);
-    while (size_--) {
-      pthread_key_delete(keys_[size_]);
+    while (size_) {
+      pthread_key_delete(keys_[--size_]);
     }
   }