Bug 53935 - crash on randomplay when cddb query is running
Summary: crash on randomplay when cddb query is running
Status: RESOLVED FIXED
Alias: None
Product: kscd
Classification: Miscellaneous
Component: general (show other bugs)
Version: 1.3.3
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Aaron J. Seigo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-02 18:57 UTC by Matthias Grimrath
Modified: 2003-02-17 07:32 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
alternate patch (1.52 KB, patch)
2003-02-03 23:06 UTC, Aaron J. Seigo
Details
kscd-3.1-2.diff (1.61 KB, text/x-diff)
2003-02-04 00:14 UTC, Matthias Grimrath
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Grimrath 2003-02-02 18:57:55 UTC
Version:           1.3.3 (using KDE KDE 3.1)
Installed from:    Compiled From Sources
OS:          Linux

How to reproduce: Start kscd with no cd running.  Make sure it doesn't
get a response from a cddb server.  Press 'randomplay', 'play' and 'next title' before the cddb query times out.

I already fixed it on my computer.

Greets,

--- kscd/kscd.cpp.orig  Sun Feb  2 17:50:16 2003
+++ kscd/kscd.cpp       Sun Feb  2 17:50:44 2003
@@ -1129,8 +1129,8 @@
         else
             statuslabel->setText(i18n("Random"));

-        if(songListCB->count()==0)
-            return;
+        //if(songListCB->count()==0)
+        //    return;
         make_random_list(); /* koz: Build a unique, once, random list */
         nextClicked();
     }
@@ -1352,7 +1352,7 @@
     /* set, the original code.  */
     if( randomonce  )
     {
-        if ( random_current == random_list.end() )
+        if ( random_current == random_list.end() )  // TODO: Forgot to init random_current?
         {
             // playing the same random list isn't very random, is it?
             make_random_list();
@@ -1367,6 +1367,7 @@
             }
         }

+        assert(!random_list.isEmpty());
         int track = *random_current + 1;
         ++random_current;
         return track;
Comment 1 Aaron J. Seigo 2003-02-03 23:06:56 UTC
Created attachment 877 [details]
alternate patch

does this patch fix the problem as well? if so, i'd prefer to apply this one...
Comment 2 Matthias Grimrath 2003-02-04 00:14:26 UTC
Subject: Re:  crash on randomplay when cddb query is running

> does this patch fix the problem as well? if so, i'd prefer to apply this
> one...

Yes, it does, and while I applied your patch I discovered another bug in the 
'randomtrack()' function.  If you insert no cd, activate looping, press 
'random' and 'next title', the code 

random_current = random_list.begin();

is executed.  Since random_list is empty, the value of random_current is 
undefined, so 

int track = *random_current + 1;

could fail with a sigsegv.  It didn't crash on my computer, still I think it 
is better to not rely upon undefined iterators, so I wrote some code around 
it.

Greets,
Matthias Grimrath


Created an attachment (id=879)
kscd-3.1-2.diff
Comment 3 Aaron J. Seigo 2003-02-04 01:08:39 UTC
*** Bug has been marked as fixed ***.