Changeset 54835 in webkit
- Timestamp:
- Feb 16, 2010 2:53:46 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r54834 r54835 1 2010-02-16 Mark Rowe <mrowe@apple.com> 2 3 Reviewed by Alexey Proskuryakov. 4 5 Bug 34974: Leak of ScheduledAction during layout tests 6 <https://bugs.webkit.org/show_bug.cgi?id=34974> 7 8 ScheduledAction::create was returning a raw pointer which was threaded down through to an OwnPtr in DOMTimer. 9 If any of the code paths in between hit an error case and returned early the raw pointer would be leaked. We 10 can avoid this by passing it as a PassOwnPtr. This will ensure that the ScheduledAction is cleaned up should 11 an error case be hit. 12 13 * bindings/js/JSDOMWindowCustom.cpp: 14 (WebCore::JSDOMWindow::setTimeout): Store the newly-created ScheduledAction in an OwnPtr and then hand it off 15 as the function argument. 16 (WebCore::JSDOMWindow::setInterval): Ditto. 17 * bindings/js/JSWorkerContextCustom.cpp: 18 (WebCore::JSWorkerContext::setTimeout): Ditto. 19 (WebCore::JSWorkerContext::setInterval): Ditto. 20 * bindings/js/ScheduledAction.cpp: 21 (WebCore::ScheduledAction::create): Return a PassOwnPtr. 22 * bindings/js/ScheduledAction.h: 23 * page/DOMTimer.cpp: 24 (WebCore::DOMTimer::DOMTimer): Update argument type. 25 (WebCore::DOMTimer::install): Ditto. 26 * page/DOMTimer.h: 27 * page/DOMWindow.cpp: 28 (WebCore::DOMWindow::setTimeout): Ditto. 29 (WebCore::DOMWindow::setInterval): Ditto. 30 * page/DOMWindow.h: 31 1 32 2010-02-16 Nikolas Zimmermann <nzimmermann@rim.com> 2 33 -
trunk/WebCore/bindings/js/JSDOMWindowCustom.cpp
r54789 r54835 913 913 JSValue JSDOMWindow::setTimeout(ExecState* exec, const ArgList& args) 914 914 { 915 ScheduledAction*action = ScheduledAction::create(exec, args, currentWorld(exec));915 OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, args, currentWorld(exec)); 916 916 if (exec->hadException()) 917 917 return jsUndefined(); … … 919 919 920 920 ExceptionCode ec = 0; 921 int result = impl()->setTimeout(action , delay, ec);921 int result = impl()->setTimeout(action.release(), delay, ec); 922 922 setDOMException(exec, ec); 923 923 … … 927 927 JSValue JSDOMWindow::setInterval(ExecState* exec, const ArgList& args) 928 928 { 929 ScheduledAction*action = ScheduledAction::create(exec, args, currentWorld(exec));929 OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, args, currentWorld(exec)); 930 930 if (exec->hadException()) 931 931 return jsUndefined(); … … 933 933 934 934 ExceptionCode ec = 0; 935 int result = impl()->setInterval(action , delay, ec);935 int result = impl()->setInterval(action.release(), delay, ec); 936 936 setDOMException(exec, ec); 937 937 -
trunk/WebCore/bindings/js/JSWorkerContextCustom.cpp
r54400 r54835 144 144 JSValue JSWorkerContext::setTimeout(ExecState* exec, const ArgList& args) 145 145 { 146 ScheduledAction*action = ScheduledAction::create(exec, args, currentWorld(exec));146 OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, args, currentWorld(exec)); 147 147 if (exec->hadException()) 148 148 return jsUndefined(); 149 149 int delay = args.at(1).toInt32(exec); 150 return jsNumber(exec, impl()->setTimeout(action , delay));150 return jsNumber(exec, impl()->setTimeout(action.release(), delay)); 151 151 } 152 152 153 153 JSValue JSWorkerContext::setInterval(ExecState* exec, const ArgList& args) 154 154 { 155 ScheduledAction*action = ScheduledAction::create(exec, args, currentWorld(exec));155 OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, args, currentWorld(exec)); 156 156 if (exec->hadException()) 157 157 return jsUndefined(); 158 158 int delay = args.at(1).toInt32(exec); 159 return jsNumber(exec, impl()->setInterval(action , delay));159 return jsNumber(exec, impl()->setInterval(action.release(), delay)); 160 160 } 161 161 -
trunk/WebCore/bindings/js/ScheduledAction.cpp
r53046 r54835 48 48 namespace WebCore { 49 49 50 ScheduledAction*ScheduledAction::create(ExecState* exec, const ArgList& args, DOMWrapperWorld* isolatedWorld)50 PassOwnPtr<ScheduledAction> ScheduledAction::create(ExecState* exec, const ArgList& args, DOMWrapperWorld* isolatedWorld) 51 51 { 52 52 JSValue v = args.at(0); -
trunk/WebCore/bindings/js/ScheduledAction.h
r52281 r54835 25 25 #include <runtime/JSCell.h> 26 26 #include <runtime/Protect.h> 27 #include <wtf/PassOwnPtr.h> 27 28 #include <wtf/Vector.h> 28 29 … … 43 44 class ScheduledAction : public Noncopyable { 44 45 public: 45 static ScheduledAction*create(JSC::ExecState*, const JSC::ArgList&, DOMWrapperWorld* isolatedWorld);46 static PassOwnPtr<ScheduledAction> create(JSC::ExecState*, const JSC::ArgList&, DOMWrapperWorld* isolatedWorld); 46 47 47 48 void execute(ScriptExecutionContext*); … … 57 58 void executeFunctionInContext(JSC::JSGlobalObject*, JSC::JSValue thisValue); 58 59 void execute(Document*); 59 #if ENABLE(WORKERS) 60 #if ENABLE(WORKERS) 60 61 void execute(WorkerContext*); 61 62 #endif -
trunk/WebCore/page/DOMTimer.cpp
r50489 r54835 44 44 static int timerNestingLevel = 0; 45 45 46 DOMTimer::DOMTimer(ScriptExecutionContext* context, ScheduledAction*action, int timeout, bool singleShot)46 DOMTimer::DOMTimer(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot) 47 47 : ActiveDOMObject(context, this) 48 48 , m_action(action) … … 83 83 } 84 84 85 int DOMTimer::install(ScriptExecutionContext* context, ScheduledAction*action, int timeout, bool singleShot)85 int DOMTimer::install(ScriptExecutionContext* context, PassOwnPtr<ScheduledAction> action, int timeout, bool singleShot) 86 86 { 87 87 // DOMTimer constructor links the new timer into a list of ActiveDOMObjects held by the 'context'. -
trunk/WebCore/page/DOMTimer.h
r50068 r54835 29 29 30 30 #include "ActiveDOMObject.h" 31 #include "ScheduledAction.h" 31 32 #include "Timer.h" 32 33 #include <wtf/OwnPtr.h> 34 #include <wtf/PassOwnPtr.h> 33 35 34 36 namespace WebCore { 35 37 36 38 class InspectorTimelineAgent; 37 class ScheduledAction;38 39 39 40 class DOMTimer : public TimerBase, public ActiveDOMObject { … … 42 43 // Creates a new timer owned by specified ScriptExecutionContext, starts it 43 44 // and returns its Id. 44 static int install(ScriptExecutionContext*, ScheduledAction*, int timeout, bool singleShot);45 static int install(ScriptExecutionContext*, PassOwnPtr<ScheduledAction>, int timeout, bool singleShot); 45 46 static void removeById(ScriptExecutionContext*, int timeoutId); 46 47 … … 60 61 61 62 private: 62 DOMTimer(ScriptExecutionContext*, ScheduledAction*, int timeout, bool singleShot);63 DOMTimer(ScriptExecutionContext*, PassOwnPtr<ScheduledAction>, int timeout, bool singleShot); 63 64 virtual void fired(); 64 65 -
trunk/WebCore/page/DOMWindow.cpp
r54182 r54835 1253 1253 } 1254 1254 1255 int DOMWindow::setTimeout( ScheduledAction*action, int timeout, ExceptionCode& ec)1255 int DOMWindow::setTimeout(PassOwnPtr<ScheduledAction> action, int timeout, ExceptionCode& ec) 1256 1256 { 1257 1257 ScriptExecutionContext* context = scriptExecutionContext(); … … 1271 1271 } 1272 1272 1273 int DOMWindow::setInterval( ScheduledAction*action, int timeout, ExceptionCode& ec)1273 int DOMWindow::setInterval(PassOwnPtr<ScheduledAction> action, int timeout, ExceptionCode& ec) 1274 1274 { 1275 1275 ScriptExecutionContext* context = scriptExecutionContext(); -
trunk/WebCore/page/DOMWindow.h
r54085 r54835 238 238 239 239 // Timers 240 int setTimeout( ScheduledAction*, int timeout, ExceptionCode&);240 int setTimeout(PassOwnPtr<ScheduledAction>, int timeout, ExceptionCode&); 241 241 void clearTimeout(int timeoutId); 242 int setInterval( ScheduledAction*, int timeout, ExceptionCode&);242 int setInterval(PassOwnPtr<ScheduledAction>, int timeout, ExceptionCode&); 243 243 void clearInterval(int timeoutId); 244 244
Note: See TracChangeset
for help on using the changeset viewer.