Reviewed by Mark Rowe.

        <rdar://problem/6130393> REGRESSION: PhotoBooth hangs after launching under TOT Webkit

        * API/JSContextRef.cpp: (JSGlobalContextRelease): Corrected a comment.

        * kjs/collector.cpp: (KJS::Heap::~Heap): Ensure that JSGlobalData is not deleted while
        sweeping the heap.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@35663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/kjs/collector.cpp b/JavaScriptCore/kjs/collector.cpp
index 75c3b76..b0b0ae5 100644
--- a/JavaScriptCore/kjs/collector.cpp
+++ b/JavaScriptCore/kjs/collector.cpp
@@ -134,7 +134,13 @@
 
 Heap::~Heap()
 {
+    // The global object is not GC protected at this point, so sweeping may delete it (and thus the global data)
+    // before other objects that may use the global data.
+    RefPtr<JSGlobalData> protect(m_globalData);
+
     delete m_markListSet;
+    m_markListSet = 0;
+
     sweep<PrimaryHeap>();
     // No need to sweep number heap, because the JSNumber destructor doesn't do anything.