diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-07-17 20:00:15 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-07-17 20:00:15 -0400 |
commit | 963c6042a7367b29e026244340f6d01ba3513dd5 (patch) | |
tree | 6e3ffb878bc9733a4d6b9c90553b26023014fbf6 | |
parent | 7052acf3c758ebc08912dee94a93c02cdd4044af (diff) | |
download | gtk+-963c6042a7367b29e026244340f6d01ba3513dd5.tar.gz |
GtkSwitch: Avoid accessing uninitialized memory
The allocation is only set in the if branch, but used outside.
Pointed out by coverity.
-rw-r--r-- | gtk/gtkswitch.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c index 3d16f16f4b..f74ccd30c5 100644 --- a/gtk/gtkswitch.c +++ b/gtk/gtkswitch.c @@ -296,20 +296,18 @@ gtk_switch_pan_gesture_drag_end (GtkGestureDrag *gesture, GtkSwitch *sw) { GtkSwitchPrivate *priv = sw->priv; + GtkWidget *widget = GTK_WIDGET (sw); GdkEventSequence *sequence; - GtkAllocation allocation; gboolean active = FALSE; sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture)); if (gtk_gesture_get_sequence_state (GTK_GESTURE (gesture), sequence) == GTK_EVENT_SEQUENCE_CLAIMED) { - gtk_widget_get_allocation (GTK_WIDGET (sw), &allocation); - /* if half the handle passed the middle of the switch, then we * consider it to be on */ - if ((priv->handle_x + (allocation.width / 4)) >= (allocation.width / 2)) + if ((priv->handle_x + (gtk_widget_get_allocated_width (widget) / 4)) >= (gtk_widget_get_allocated_width (widget) / 2)) active = TRUE; } else if (!gtk_gesture_handles_sequence (priv->multipress_gesture, sequence)) @@ -318,12 +316,12 @@ gtk_switch_pan_gesture_drag_end (GtkGestureDrag *gesture, return; if (active) - priv->handle_x = allocation.width / 2; + priv->handle_x = gtk_widget_get_allocated_width (widget) / 2; else priv->handle_x = 0; gtk_switch_set_active (sw, active); - gtk_widget_queue_draw (GTK_WIDGET (sw)); + gtk_widget_queue_draw (widget); } static gboolean |