APPROVE COMMIT 21.5
I already patched scrollbar-x.c to fix code where a pointer was
dereferenced twice, then checked to see if it is NULL. This patch fixes
the same problem in the same place in scrollbar-gtk.c and
scrollbar-msw.c.
src/ChangeLog addition:
2006-06-29 Jerry James <james(a)xemacs.org>
* 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.
xemacs-21.5 source patch:
Diff command: cvs -q diff -uN
Files affected: src/scrollbar-msw.c src/scrollbar-gtk.c
Index: src/scrollbar-gtk.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/scrollbar-gtk.c,v
retrieving revision 1.19
diff -d -u -r1.19 scrollbar-gtk.c
--- src/scrollbar-gtk.c 2005/10/25 08:32:48 1.19
+++ src/scrollbar-gtk.c 2006/06/29 16:48:59
@@ -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));
+ }
- if (instance->scrollbar_data)
- xfree (instance->scrollbar_data, void *);
+ xfree (instance->scrollbar_data, void *);
+ }
}
/* A device method. */
Index: src/scrollbar-msw.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/scrollbar-msw.c,v
retrieving revision 1.31
diff -d -u -r1.31 scrollbar-msw.c
--- src/scrollbar-msw.c 2005/10/25 08:32:49 1.31
+++ src/scrollbar-msw.c 2006/06/29 16:48:59
@@ -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;
-
- 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 *);
+ {
+ 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));
+ xfree (sb->scrollbar_data, void *);
+ }
}
static void
--
Jerry James, Assistant Professor james(a)xemacs.org
Computer Science Department
http://www.cs.usu.edu/~jerry/
Utah State University