Changeset 26376 in webkit


Ignore:
Timestamp:
Oct 11, 2007 5:16:56 PM (17 years ago)
Author:
honeycutt
Message:

2007-10-11 Jon Honeycutt <jhoneycutt@apple.com>

Reviewed by Anders.

Handle a race condition that could arise if a plugin was loaded while it
was scheduled to be freed: check whether the timer that schedules
library frees is active in PluginPackageWin::load().

  • plugins/win/PluginPackageWin.cpp: (WebCore::PluginPackageWin::freeLibrarySoon): Added assertions (WebCore::PluginPackageWin::freeLibraryTimerFired): Added assertion (WebCore::PluginPackageWin::load): If we are scheduled to free this library, cancel the timer, and don't call LoadLibrary
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r26374 r26376  
     12007-10-11  Jon Honeycutt  <jhoneycutt@apple.com>
     2
     3        Reviewed by Anders.
     4
     5        Handle a race condition that could arise if a plugin was loaded while it
     6        was scheduled to be freed: check whether the timer that schedules
     7        library frees is active in PluginPackageWin::load().
     8
     9        * plugins/win/PluginPackageWin.cpp:
     10        (WebCore::PluginPackageWin::freeLibrarySoon): Added assertions
     11        (WebCore::PluginPackageWin::freeLibraryTimerFired): Added assertion
     12        (WebCore::PluginPackageWin::load): If we are scheduled to free this
     13        library, cancel the timer, and don't call LoadLibrary
     14
    1152007-10-11  Justin Garcia  <justin.garcia@apple.com>
    216
  • trunk/WebCore/plugins/win/PluginPackageWin.cpp

    r26364 r26376  
    8484void PluginPackageWin::freeLibrarySoon()
    8585{
     86    ASSERT(!m_freeLibraryTimer.isActive());
     87    ASSERT(m_module);
     88    ASSERT(m_loadCount == 0);
     89
    8690    m_freeLibraryTimer.startOneShot(0);
    8791}
     
    9094{
    9195    ASSERT(m_module);
    92 
    93     FreeLibrary(m_module);
     96    ASSERT(m_loadCount == 0);
     97
     98    ::FreeLibrary(m_module);
    9499    m_module = 0;
    95100}
     
    158163bool PluginPackageWin::load()
    159164{
    160     if (m_isLoaded) {
     165    if (m_freeLibraryTimer.isActive()) {
     166        ASSERT(m_module);
     167        m_freeLibraryTimer.stop();
     168    } else if (m_isLoaded) {
    161169        m_loadCount++;
    162170        return true;
    163     }
    164 
    165     WCHAR currentPath[MAX_PATH];
    166 
    167     if (!::GetCurrentDirectoryW(MAX_PATH, currentPath))
    168         return false;
    169 
    170     String path = m_path.substring(0, m_path.reverseFind('\\'));
    171 
    172     if (!::SetCurrentDirectoryW(path.charactersWithNullTermination()))
    173         return false;
    174 
    175     // Load the library
    176     m_module = ::LoadLibraryW(m_path.charactersWithNullTermination());
    177 
    178     if (!::SetCurrentDirectoryW(currentPath)) {
    179         if (m_module)
    180             ::FreeLibrary(m_module);
    181         return false;
     171    } else {
     172        WCHAR currentPath[MAX_PATH];
     173
     174        if (!::GetCurrentDirectoryW(MAX_PATH, currentPath))
     175            return false;
     176
     177        String path = m_path.substring(0, m_path.reverseFind('\\'));
     178
     179        if (!::SetCurrentDirectoryW(path.charactersWithNullTermination()))
     180            return false;
     181
     182        // Load the library
     183        m_module = ::LoadLibraryW(m_path.charactersWithNullTermination());
     184
     185        if (!::SetCurrentDirectoryW(currentPath)) {
     186            if (m_module)
     187                ::FreeLibrary(m_module);
     188            return false;
     189        }
    182190    }
    183191
Note: See TracChangeset for help on using the changeset viewer.