[netspeed] Fix quality calculation and failed assertion; Fixes #567079



commit 1848ba4107e28c2847b880d01854528197258df8
Author: Jörgen Scheibengruber <mfcn gmx de>
Date:   Sat Jun 5 14:39:13 2010 +0300

    Fix quality calculation and failed assertion; Fixes #567079

 src/netspeed.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/src/netspeed.c b/src/netspeed.c
index 488696f..cbb77e0 100644
--- a/src/netspeed.c
+++ b/src/netspeed.c
@@ -351,9 +351,8 @@ update_quality_icon(NetspeedApplet *applet)
 	unsigned int q;
 	
 	q = (applet->devinfo.qual);
-	q = logf (q / 3.0f) + 0.25f;
-
-	g_assert(q >= 0 && q < 4);
+	q /= 25;
+	q = CLAMP(q, 0, 3); /* q out of range would crash when accessing qual_pixbufs[q] */
 	gtk_image_set_from_pixbuf (GTK_IMAGE(applet->qual_pix), applet->qual_pixbufs[q]);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]