[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Bug in qRemovePostRoutine
From:       Waldo Bastian <bastian () kde ! org>
Date:       2002-02-26 1:34:45
[Download RAW message or body]

In Qt 3.0.2, or what is almost Qt 3.0.2, the qRemovePostRoutine can lock up 
due to an error in the logic of the loop.

The code looks like:

Q_EXPORT void qRemovePostRoutine( QtCleanUpFunction p )
{
    if ( !postRList ) return;
    QVFuncList::Iterator it = postRList->begin();
    while ( it != postRList->end() ) {
        if ( *it == p ) {
            postRList->remove( it );
            it = postRList->begin();
        }
    }
}

When the postRList contains two or more functions and the function p is not 
the first function in the list, the above while loop will never reach its 
end-condition:

Given postRList->begin() != postRList->end() and *postRList->begin() != p then

1) At the first iteration the while-condition will be true because it == 
postRList->begin().
2) The if condition will be false and no action will be taken whatsoever.
3) The loop returns to the start of the while-loop. The iterator it has not 
changed since the last time the control was at this point in the code. 
Neither has there been any operation on either postRList or p. Therefor the 
result of the while-condition will be unchanged and effectively we will have 
returned to the state of 1) There are no paths out of this state.

Cheers,
Waldo
-- 
Advanced technology only happens when people take a basic idea and add to it.
 -- Bob Bemer

_______________________________________________
KMail Developers mailing list
kmail@mail.kde.org
http://mail.kde.org/mailman/listinfo/kmail
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic