Bug 238503 - KRandomSequence::randomize() crashes when passed an empty list
Summary: KRandomSequence::randomize() crashes when passed an empty list
Status: RESOLVED DUPLICATE of bug 226738
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: kdecore (show other bugs)
Version: 4.4
Platform: Compiled Sources Unspecified
: NOR crash
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
: 238499 239976 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-05-22 16:36 UTC by Soren Harward
Modified: 2010-05-29 18:18 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Soren Harward 2010-05-22 16:36:38 UTC
Version:            (using KDE 4.4.3)
Installed from:    Compiled From Sources

KRandomSequence::randomize( QList<T>& list ), defined at krandomsequence.h:109, does not ever check to see whether the list passed to it is empty.  Consequently, if the list passed as an argument is empty, the call to list.takeFirst() on line 109 causes a crash with an failed ASSERT() in Qt::List.

I suggest inserting the following code between lines 111 and 112:

if ( list.isEmpty() )
    return l;
Comment 1 Christoph Feck 2010-05-22 18:55:00 UTC

*** This bug has been marked as a duplicate of bug 226738 ***
Comment 2 Myriam Schweingruber 2010-05-29 17:50:50 UTC
Christoph: how can this KDE 4.4.3 bug be a duplicate of a bug fixed months ago in an older version of KDE? One of these bugs needs to be reopened, but my knowledge about kdelibs is to poor to know which one.
Comment 3 Myriam Schweingruber 2010-05-29 17:51:54 UTC
*** Bug 238499 has been marked as a duplicate of this bug. ***
Comment 4 Myriam Schweingruber 2010-05-29 17:52:29 UTC
*** Bug 239976 has been marked as a duplicate of this bug. ***
Comment 5 Christoph Feck 2010-05-29 18:18:45 UTC
The only explanation I have for bug 239976 appearing is that Amarok is compiled against 4.4.0 (or older) kdelibs headers. The randomize() function is inlined, so just updating kdelibs does not fix the issue; Amarok has to be (re)compiled against at least 4.4.1 kdelibs headers.

I checked 4.4 branch, and Anne-Marie did backport the fix, see http://websvn.kde.org/?revision=1091061&view=revision.