[gtk+/gtk-style-context: 122/276] GtkStyleContext: Don crash on empty	class sets.
- From: Carlos Garnacho <carlosg src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [gtk+/gtk-style-context: 122/276] GtkStyleContext: Don crash on empty	class sets.
 
- Date: Sat, 23 Oct 2010 19:05:21 +0000 (UTC)
 
commit b95788078c4625973dee4332f243ad49928f034c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jul 18 18:40:48 2010 +0200
    GtkStyleContext: Don crash on empty class sets.
 gtk/gtkstylecontext.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 71f8c83..c1ec55d 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -642,16 +642,21 @@ gtk_style_context_restore (GtkStyleContext *context)
 }
 
 static gboolean
-style_class_find (GArray       *array,
-                  GQuark        class_quark,
-                  guint        *position)
+style_class_find (GArray *array,
+                  GQuark  class_quark,
+                  guint  *position)
 {
   guint min, max, mid;
   gboolean found = FALSE;
 
+  if (position)
+    *position = 0;
+
+  if (!array || array->len == 0)
+    return FALSE;
+
   min = 0;
   max = array->len - 1;
-  mid = max - min / 2;
 
   do
     {
@@ -676,16 +681,21 @@ style_class_find (GArray       *array,
 }
 
 static gboolean
-child_style_class_find (GArray       *array,
-                        GQuark        class_quark,
-                        guint        *position)
+child_style_class_find (GArray *array,
+                        GQuark  class_quark,
+                        guint  *position)
 {
   guint min, max, mid;
   gboolean found = FALSE;
 
+  if (position)
+    *position = 0;
+
+  if (!array || array->len == 0)
+    return FALSE;
+
   min = 0;
   max = array->len - 1;
-  mid = max - min / 2;
 
   do
     {
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]