# HG changeset patch # User james # Date 1151600340 0 # Node ID 20773f9b7bc02780c90072ebc620a05a0976cb29 # Parent 71532ccbd8e388b04fa0c468d63d8f58d53145ae [xemacs-hg @ 2006-06-29 16:58:59 by james] Check scrollbar instance data for NULLness before dereferencing. diff -r 71532ccbd8e3 -r 20773f9b7bc0 src/ChangeLog --- a/src/ChangeLog Thu Jun 29 14:52:00 2006 +0000 +++ b/src/ChangeLog Thu Jun 29 16:59:00 2006 +0000 @@ -1,3 +1,10 @@ +2006-06-29 Jerry James + + * scrollbar-gtk.c (gtk_free_scrollbar_instance): Compare + instance->scrollbar_data against NULL before using it. + * scrollbar-msw.c (mswindows_free_scrollbar_instance): Compare + sb->scrollbar_data against NULL before using it. + 2006-06-22 Jerry James * redisplay-gtk.c (gtk_output_display_block): Fix a Dynarr leak. diff -r 71532ccbd8e3 -r 20773f9b7bc0 src/scrollbar-gtk.c --- a/src/scrollbar-gtk.c Thu Jun 29 14:52:00 2006 +0000 +++ b/src/scrollbar-gtk.c Thu Jun 29 16:59:00 2006 +0000 @@ -56,14 +56,16 @@ static void gtk_free_scrollbar_instance (struct scrollbar_instance *instance) { - if (SCROLLBAR_GTK_WIDGET (instance)) + if (instance->scrollbar_data) { - gtk_widget_hide_all (SCROLLBAR_GTK_WIDGET (instance)); - gtk_widget_destroy (SCROLLBAR_GTK_WIDGET (instance)); + if (SCROLLBAR_GTK_WIDGET (instance)) + { + gtk_widget_hide_all (SCROLLBAR_GTK_WIDGET (instance)); + gtk_widget_destroy (SCROLLBAR_GTK_WIDGET (instance)); + } + + xfree (instance->scrollbar_data, void *); } - - if (instance->scrollbar_data) - xfree (instance->scrollbar_data, void *); } /* A device method. */ diff -r 71532ccbd8e3 -r 20773f9b7bc0 src/scrollbar-msw.c --- a/src/scrollbar-msw.c Thu Jun 29 14:52:00 2006 +0000 +++ b/src/scrollbar-msw.c Thu Jun 29 16:59:00 2006 +0000 @@ -90,17 +90,19 @@ static void mswindows_free_scrollbar_instance (struct scrollbar_instance *sb) { - void *opaque = - (void *) qxeGetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_USERDATA); - Lisp_Object ptr; + if (sb->scrollbar_data) + { + void *opaque = + (void *) qxeGetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_USERDATA); + Lisp_Object ptr; - ptr = VOID_TO_LISP (opaque); - assert (OPAQUE_PTRP (ptr)); - ptr = Fremhash (ptr, Vmswindows_scrollbar_instance_table); - assert (!NILP (ptr)); - DestroyWindow (SCROLLBAR_MSW_HANDLE (sb)); - if (sb->scrollbar_data) - xfree (sb->scrollbar_data, void *); + ptr = VOID_TO_LISP (opaque); + assert (OPAQUE_PTRP (ptr)); + ptr = Fremhash (ptr, Vmswindows_scrollbar_instance_table); + assert (!NILP (ptr)); + DestroyWindow (SCROLLBAR_MSW_HANDLE (sb)); + xfree (sb->scrollbar_data, void *); + } } static void