2008-01-12 Cameron Zwarich <cwzwarich@uwaterloo.ca>
authormrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 13 Jan 2008 04:52:01 +0000 (04:52 +0000)
committermrowe@apple.com <mrowe@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 13 Jan 2008 04:52:01 +0000 (04:52 +0000)
        Reviewed by Mark Rowe.

        Fix http://bugs.webkit.org/show_bug.cgi?id=16852
        Fixes leaking of ActivationStackNode objects.

        * kjs/JSGlobalObject.cpp:
        (KJS::JSGlobalObject::deleteActivationStack):
        (KJS::JSGlobalObject::~JSGlobalObject):
        (KJS::JSGlobalObject::init):
        (KJS::JSGlobalObject::reset):
        * kjs/JSGlobalObject.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29443 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/JSGlobalObject.cpp
JavaScriptCore/kjs/JSGlobalObject.h

index ea91db2..3a1c079 100644 (file)
@@ -1,3 +1,17 @@
+2008-01-12  Cameron Zwarich  <cwzwarich@uwaterloo.ca>
+
+        Reviewed by Mark Rowe.
+
+        Fix http://bugs.webkit.org/show_bug.cgi?id=16852
+        Fixes leaking of ActivationStackNode objects.
+
+        * kjs/JSGlobalObject.cpp:
+        (KJS::JSGlobalObject::deleteActivationStack):
+        (KJS::JSGlobalObject::~JSGlobalObject):
+        (KJS::JSGlobalObject::init):
+        (KJS::JSGlobalObject::reset):
+        * kjs/JSGlobalObject.h:
+
 2008-01-12  Darin Adler  <darin@apple.com>
 
         - try to fix Qt Windows build
index d06735c..33471fa 100644 (file)
@@ -90,6 +90,15 @@ static inline unsigned getCurrentTime() {
 
 JSGlobalObject* JSGlobalObject::s_head = 0;
 
+void JSGlobalObject::deleteActivationStack()
+{
+    ActivationStackNode* prevNode = 0;
+    for (ActivationStackNode* currentNode = d()->activations; currentNode; currentNode = prevNode) {
+        prevNode = currentNode->prev;
+        delete currentNode;
+    }
+}
+
 JSGlobalObject::~JSGlobalObject()
 {
     ASSERT(JSLock::currentThreadIsHoldingLock());
@@ -103,6 +112,8 @@ JSGlobalObject::~JSGlobalObject()
     if (s_head == this)
         s_head = 0;
     
+    deleteActivationStack();
+    
     delete d();
 }
 
@@ -128,6 +139,8 @@ void JSGlobalObject::init()
     d()->recursion = 0;
     d()->debugger = 0;
     
+    d()->activations = 0;
+    
     reset(prototype());
 }
 
@@ -202,7 +215,10 @@ void JSGlobalObject::reset(JSValue* prototype)
 
     ExecState* exec = &d()->globalExec;
 
-    d()->activations = new ActivationStackNode;
+    deleteActivationStack();
+    ActivationStackNode* newStackNode = new ActivationStackNode;
+    newStackNode->prev = 0;    
+    d()->activations = newStackNode;
     d()->activationCount = 0;
 
     // Prototypes
index 86a12b0..c27e529 100644 (file)
@@ -244,6 +244,7 @@ namespace KJS {
         bool checkTimeout();
         void resetTimeoutCheck();
 
+        void deleteActivationStack();
         void checkActivationCount();
 
         static JSGlobalObject* s_head;