Bug 138161 - kslideshow.kss crashes quietly when "Random Position" is selected
Summary: kslideshow.kss crashes quietly when "Random Position" is selected
Status: RESOLVED FIXED
Alias: None
Product: kscreensaver
Classification: Miscellaneous
Component: screensavers (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR crash (vote)
Target Milestone: ---
Assignee: kscreensaver bugs tracking
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-30 15:05 UTC by Bryant Hansen
Modified: 2008-05-19 17:59 UTC (History)
0 users

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 Bryant Hansen 2006-11-30 15:05:31 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    Gentoo Packages
Compiler:          gcc 4.1.1 
OS:                Linux

The "Slide Show" screen saver in KDE Control Center only plays a handful of slides from a large collection and then dies.  The problem only occurs when I have the "Random Position" setting checked.

Today I determined the exact cause of the problem: it's in the calculation of the random position. When either the image width or the height matches the screen dimensions exactly, a divide-by-zero error results and the screen saver crashes.

The offending lines of code are lines 778 and 779 in screensaver.cpp (KDE 3.5.5):

          x = rand() % (ww - iw);
          y = rand() % (wh - ih); 

One possible fix, which I've tested successfully, is to change the boundary-checking condition above.

Line 759:
      if(iw > ww || ih > wh)

Should be changed to:
      if(iw >= ww || ih >= wh)
Comment 1 Oswald Buddenhagen 2007-05-18 22:57:14 UTC
SVN commit 666124 by ossi:

backport: fix div by 0
BUG: 138161


 M  +1 -1      slideshow.cpp  


--- branches/KDE/3.5/kdeartwork/kscreensaver/kdesavers/slideshow.cpp #666123:666124
@@ -756,7 +756,7 @@
     }
     else
     {
-      if(iw > ww || ih > wh)
+      if(iw >= ww || ih >= wh)
       {
         fx = (double)ww / iw;
 	fy = (double)wh / ih;