[gtk+] range: Avoid division by zero
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] range: Avoid division by zero
- Date: Thu, 20 Jul 2017 01:55:28 +0000 (UTC)
commit 993998085f3ba4eebe0ac83737f4fdcc1a40de9a
Author: Timm Bäder <mail baedert org>
Date: Thu Jun 29 15:28:24 2017 +0200
range: Avoid division by zero
gtk/gtkrange.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index f74f1b2..2c4d208 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -1425,8 +1425,11 @@ gtk_range_allocate_trough (GtkGizmo *gizmo,
gtk_widget_size_allocate (priv->slider_widget, &slider_alloc);
gtk_widget_get_clip (priv->slider_widget, out_clip);
- value = (gtk_adjustment_get_value (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment)) /
- (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment));
+ if (gtk_adjustment_get_lower (priv->adjustment) == gtk_adjustment_get_upper (priv->adjustment))
+ value = 0;
+ else
+ value = (gtk_adjustment_get_value (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment)) /
+ (gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_lower (priv->adjustment));
if (priv->show_fill_level &&
gtk_adjustment_get_upper (priv->adjustment) - gtk_adjustment_get_page_size (priv->adjustment) -
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]