Changeset 27196 in webkit


Ignore:
Timestamp:
Oct 28, 2007 6:29:48 PM (17 years ago)
Author:
mjs
Message:

JavaScriptCore:

Reviewed by Mark.


  • Added assertions to protect against adding empty or deleted keys to a HashTable
  • wtf/HashTable.h: (WTF::HashTable::lookup): (WTF::HashTable::lookupForWriting): (WTF::HashTable::fullLookupForWriting): (WTF::HashTable::add):

WebCore:

Reviewed by Mark.

  • bindings/js/kjs_window.cpp: (KJS::Window::installTimeout): Avoid putting in or accessing empty or deleted keys. (KJS::Window::clearTimeout): ditto
  • manual-tests/bad-clearTimeout-crash.html: Added. Automated test not possible.
Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r27193 r27196  
     12007-10-28  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Mark.
     4       
     5        - Added assertions to protect against adding empty or deleted keys to a HashTable
     6
     7        * wtf/HashTable.h:
     8        (WTF::HashTable::lookup):
     9        (WTF::HashTable::lookupForWriting):
     10        (WTF::HashTable::fullLookupForWriting):
     11        (WTF::HashTable::add):
     12
    1132007-10-28  Darin Adler  <darin@apple.com>
    214
  • trunk/JavaScriptCore/wtf/HashTable.h

    r27176 r27196  
    403403    {
    404404        ASSERT(m_table);
     405#ifndef ASSERT_DISABLED
     406        if (HashFunctions::safeToCompareToEmptyOrDeleted) {
     407            ASSERT(!HashTranslator::equal(KeyTraits::emptyValue(), key));
     408            ASSERT(!HashTranslator::equal(KeyTraits::deletedValue(), key));
     409        }
     410#endif
    405411
    406412        int k = 0;
     
    447453    {
    448454        ASSERT(m_table);
     455#ifndef ASSERT_DISABLED
     456        if (HashFunctions::safeToCompareToEmptyOrDeleted) {
     457            ASSERT(!HashTranslator::equal(KeyTraits::emptyValue(), key));
     458            ASSERT(!HashTranslator::equal(KeyTraits::deletedValue(), key));
     459        }
     460#endif
    449461
    450462        int k = 0;
     
    498510    {
    499511        ASSERT(m_table);
     512#ifndef ASSERT_DISABLED
     513        if (HashFunctions::safeToCompareToEmptyOrDeleted) {
     514            ASSERT(!HashTranslator::equal(KeyTraits::emptyValue(), key));
     515            ASSERT(!HashTranslator::equal(KeyTraits::deletedValue(), key));
     516        }
     517#endif
    500518
    501519        int k = 0;
     
    548566    inline pair<typename HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::iterator, bool> HashTable<Key, Value, Extractor, HashFunctions, Traits, KeyTraits>::add(const T& key, const Extra& extra)
    549567    {
     568#ifndef ASSERT_DISABLED
     569        if (HashFunctions::safeToCompareToEmptyOrDeleted) {
     570            ASSERT(!HashTranslator::equal(KeyTraits::emptyValue(), key));
     571            ASSERT(!HashTranslator::equal(KeyTraits::deletedValue(), key));
     572        }
     573#endif
     574
    550575        invalidateIterators();
    551576
  • trunk/WebCore/ChangeLog

    r27190 r27196  
     12007-10-28  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Mark.
     4
     5        - fixed REGRESSION(r27176): Reproducible crash while trying to order dinner makes bdash sad
     6        http://bugs.webkit.org/show_bug.cgi?id=15731
     7
     8        * bindings/js/kjs_window.cpp:
     9        (KJS::Window::installTimeout): Avoid putting in or accessing empty or deleted keys.
     10        (KJS::Window::clearTimeout): ditto
     11        * manual-tests/bad-clearTimeout-crash.html: Added. Automated test not possible.
     12
    1132007-10-28  Kevin Ollivier  <kevino@theolliviers.com>
    214
  • trunk/WebCore/bindings/js/kjs_window.cpp

    r27118 r27196  
    15221522{
    15231523    int timeoutId = ++lastUsedTimeoutId;
     1524
     1525    // avoid wraparound going negative on us
     1526    if (timeoutId <= 0)
     1527        timeoutId = 1;
     1528
    15241529    int nestLevel = timerNestingLevel + 1;
    15251530    DOMWindowTimer* timer = new DOMWindowTimer(timeoutId, nestLevel, this, a);
     
    15931598void Window::clearTimeout(int timeoutId, bool delAction)
    15941599{
     1600    // timeout IDs have to be positive, and 0 and -1 are unsafe to
     1601    // even look up since they are the empty and deleted value
     1602    // respectively
     1603    if (timeoutId <= 0)
     1604        return;
     1605
    15951606    WindowPrivate::TimeoutsMap::iterator it = d->m_timeouts.find(timeoutId);
    15961607    if (it == d->m_timeouts.end())
Note: See TracChangeset for help on using the changeset viewer.