Re: testgtk crashes in bsearch
- From: Owen Taylor <otaylor redhat com>
- To: "Padraig O'Briain" <Padraig Obriain Sun COM>
- Cc: gtk-devel-list gnome org
- Subject: Re: testgtk crashes in bsearch
- Date: 10 Sep 2001 06:57:45 -0400
"Padraig O'Briain" <Padraig Obriain Sun COM> writes:
> Following up on my own mail.
>
> I have found that the following change fixes the problem. May I commit?
>
> cvs server: Diffing .
> Index: gtkstyle.c
> ===================================================================
> RCS file: /cvs/gnome/gtk+/gtk/gtkstyle.c,v
> retrieving revision 1.76
> diff -u -p -r1.76 gtkstyle.c
> --- gtkstyle.c 2001/09/08 17:55:02 1.76
> +++ gtkstyle.c 2001/09/10 10:03:03
> @@ -1307,12 +1307,16 @@ _gtk_style_peek_property_value (GtkStyle
> /* lookup, or insert value if not yet present */
> key.widget_type = widget_type;
> key.pspec = pspec;
> - pcache = bsearch (&key,
> - style->property_cache->data, style->property_cache->len,
> - sizeof (PropertyValue), style_property_values_cmp);
> - if (pcache)
> - return &pcache->value;
>
> + if (style->property_cache->len > 0)
> + {
> + /* On Solaris bsearch does not check that the length is non-zero */
> + pcache = bsearch (&key,
> + style->property_cache->data, style->property_cache->len,
> + sizeof (PropertyValue), style_property_values_cmp);
> + if (pcache)
> + return &pcache->value;
> + }
> i = 0;
> while (i < style->property_cache->len &&
> style_property_values_cmp (&key, &g_array_index (style->property_cache,
> PropertyValue, i)) >= 0)
I've committed the following patch which is perhaps marginally
more elegant.
Thanks for finding this,
Owen
Index: gtk/gtkstyle.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkstyle.c,v
retrieving revision 1.76
diff -u -r1.76 gtkstyle.c
--- gtk/gtkstyle.c 2001/09/08 17:55:02 1.76
+++ gtk/gtkstyle.c 2001/09/10 10:52:53
@@ -1303,15 +1303,16 @@
/* need value cache array */
if (!style->property_cache)
style->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue));
-
- /* lookup, or insert value if not yet present */
- key.widget_type = widget_type;
- key.pspec = pspec;
- pcache = bsearch (&key,
- style->property_cache->data, style->property_cache->len,
- sizeof (PropertyValue), style_property_values_cmp);
- if (pcache)
- return &pcache->value;
+ else
+ {
+ key.widget_type = widget_type;
+ key.pspec = pspec;
+ pcache = bsearch (&key,
+ style->property_cache->data, style->property_cache->len,
+ sizeof (PropertyValue), style_property_values_cmp);
+ if (pcache)
+ return &pcache->value;
+ }
i = 0;
while (i < style->property_cache->len &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]