Bug 238503

Summary: KRandomSequence::randomize() crashes when passed an empty list
Product: [Frameworks and Libraries] kdelibs Reporter: Soren Harward <stharward>
Component: kdecoreAssignee: kdelibs bugs <kdelibs-bugs>
Status: RESOLVED DUPLICATE    
Severity: crash CC: aedo999, cfeck, mprizee, myriam
Priority: NOR    
Version: 4.4   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Unspecified   
Latest Commit: Version Fixed In:

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.