Bug 749678 - 5/5 - fix dangling TLS pointer - r=jrmuizel
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 08 May 2012 09:47:34 -0400
changeset 95766 800b381a1638b17cff5925fac900371018aa9eda
parent 95765 0bd4182e0e61d0f4591a7dcd37391b88245ced60
child 95767 9c9dc2ee76effc55aa83930fac94c13d3b75be8c
push id1439
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 20:19:22 +0000
treeherdermozilla-aurora@ea74834dccd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs749678
milestone15.0a1
Bug 749678 - 5/5 - fix dangling TLS pointer - r=jrmuizel
gfx/gl/GLContext.h
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -535,17 +535,23 @@ struct THEBES_API ContextFormat
  */
 class GLContextTLSStorage
 {
     struct Storage
     {
         GLContext *mCurrentGLContext;
 
         NS_INLINE_DECL_REFCOUNTING(Storage)
+
         Storage() : mCurrentGLContext(nsnull) {}
+
+        ~Storage() {
+            // avoid keeping a dangling TLS pointer to the Storage object being destroyed
+            tls::set<Storage>(sTLSKey, nsnull);
+        }
     };
 
     nsRefPtr<Storage> mStorage;
     static tls::key sTLSKey;
     static bool sTLSKeyAlreadyCreated;
 
 public: