Changeset 74983 in webkit


Ignore:
Timestamp:
Jan 4, 2011 11:29:19 AM (13 years ago)
Author:
dbates@webkit.org
Message:

2011-01-04 Daniel Bates <dbates@rim.com>

Reviewed by Adam Roben.

LEAK: Deallocate instance of ThreadFunctionInvocation if thread creation fails
https://bugs.webkit.org/show_bug.cgi?id=51860

  • wtf/ThreadingWin.cpp: (WTF::createThreadInternal):
Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r74978 r74983  
     12011-01-04  Daniel Bates  <dbates@rim.com>
     2
     3        Reviewed by Adam Roben.
     4
     5        LEAK: Deallocate instance of ThreadFunctionInvocation if thread creation fails
     6        https://bugs.webkit.org/show_bug.cgi?id=51860
     7
     8        * wtf/ThreadingWin.cpp:
     9        (WTF::createThreadInternal):
     10
    1112011-01-04  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
    212
  • trunk/Source/JavaScriptCore/wtf/ThreadingWin.cpp

    r74977 r74983  
    209209    unsigned threadIdentifier = 0;
    210210    ThreadIdentifier threadID = 0;
    211     ThreadFunctionInvocation* invocation = new ThreadFunctionInvocation(entryPoint, data);
     211    OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(new ThreadFunctionInvocation(entryPoint, data));
    212212#if OS(WINCE)
    213213    // This is safe on WINCE, since CRT is in the core and innately multithreaded.
    214214    // On desktop Windows, need to use _beginthreadex (not available on WinCE) if using any CRT functions
    215     HANDLE threadHandle = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)wtfThreadEntryPoint, invocation, 0, (LPDWORD)&threadIdentifier);
     215    HANDLE threadHandle = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)wtfThreadEntryPoint, invocation.get(), 0, (LPDWORD)&threadIdentifier);
    216216#else
    217     HANDLE threadHandle = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, wtfThreadEntryPoint, invocation, 0, &threadIdentifier));
     217    HANDLE threadHandle = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, wtfThreadEntryPoint, invocation.get(), 0, &threadIdentifier));
    218218#endif
    219219    if (!threadHandle) {
     
    227227        return 0;
    228228    }
     229
     230    // The thread will take ownership of invocation.
     231    invocation.leakPtr();
    229232
    230233    threadID = static_cast<ThreadIdentifier>(threadIdentifier);
Note: See TracChangeset for help on using the changeset viewer.