PATCH 21.4
DO NOT APPLY THIS PATCH: It is causing an assertion failure in the md5
tests.  I will track it down and send a superceding version of this
patch.  I'm only sending this because I spent so much time writing
it.:-)  Please review it anyway.  If there is anything controversial,
I'm happy to split it out as a separate patch.
This is the 21.4 version of the patches I've been applying to 21.5
recently, to fix various problems (or potential problems) found by
various code analysis tools.  I ran the tools over the 21.4 base and
found a few that don't appear in the 21.5 code base, as well.  I won't
repeat the rationale for those that have already been sent in for 21.5,
but will describe the new changes for 21.4.
EmacsShell-sub.c: If the for loop terminates because i becomes too
large, then child will not have been initialized, so dereferencing it is
bad.  Let's just dereference it where we set it.
dumper.c: The array 'backtrace' has 65536 elements.  Here we are
checking to see if we have overflowed the array, but the check is off by
one.  If me == 65536, then we will try to access backtrace[65536], but
that's the first bad element, not the last good one.
editfns.c: The array warnpath is shorter than the array path, but we
were copying from path to warnpath without checking how many bytes were
transferred.  I tried to rationalize the code a bit.  This code was
rewritten for 21.5.
keymap.c: Actually, this problem appears in 21.5 too.  I'll send in a
patch for it later.  We are allocating a new array and then throwing it
away.  It looks like we are rolling our own realloc() here.  I don't
understand that, but we might as well finish the job instead of leaking
memory.
sound.c: We're discussing this one on xemacs-beta right now.  This is my
preferred solution.
lwlib/ChangeLog addition:
2006-06-22  Jerry James  <james(a)xemacs.org>
	* lwlib-Xlw.c (xlw_scrollbar_callback): Do not dereference
	instance before checking whether it is NULL.
	* xlwmenu.c (xlw_map_menu): Prevent uninitialized access to root
	and waste.
src/ChangeLog addition:
2006-06-22  Jerry James  <james(a)xemacs.org>
	* EmacsShell-sub.c (ChangeManaged):
	* device-x.c (x_IO_error_handler): Do not dereference d if it is
	NULL.
	* dgif_lib.c (DGifCloseFile): Do not dereference GifFile before
	checking if it is NULL.  Also fix a memory leak.
	* dialog-x.c (dbox_selection_callback): Ensure f is non-NULL, then
	dereference it, not the other way around.
	* dumper.c (pdump_register_object): Fix off-by-one array bounds
	overflow check.
	* dumper.c (pdump_register_struct): Ditto.
	* editfns.c (Ftemp_directory): Don't let a copy from (long) path
	to (short) warnpath overflow warnpath.
	* extents.c (detach_all_extents): Call extent_list_delete_all with
	a non-NULL parameter only.
	* glyphs-widget.c (widget_query_geometry): Guard against possibly
	NULL width and height.
	* input-method-xlib.c (XIM_SetGeometry): Do not dereference f or
	xic before checking if they are NULL.
	* keymap.c (where_is_recursive_mapper): Don't throw away the newly
	allocated array.
	* md5.c (Fmd5): Check whether Lstream_read encountered an error.
	* nas.c (Err): Fix a memory leak.
	* redisplay-gtk.c (gtk_output_display_block): Fix a Dynarr leak.
	Don't create the buffer if there is nothing to do.
	* redisplay-msw.c (mswindows_output_display_block): Ditto.
	* redisplay-output.c (redisplay_output_layout): Ditto.
	* redisplay-tty.c (tty_output_display_block): Ditto.
	* redisplay-x.c (x_output_display_block): Ditto.
	* scrollbar-gtk.c (gtk_free_scrollbar_instance): Do not
	dereference instance->scrollbar_data if it is NULL.
	* scrollbar-x.c (x_free_scrollbar_instance): Ditto.
	* scrollbar-msw.c (mswindows_free_scrollbar_instance): Ditto, but
	for sb->scrollbar_data.
	* sound.c (init_native_sound): Avoid a buffer overflow by
	allocating a buffer with the appropriate size.
xemacs-21.4 source patch:
Diff command:   cvs -q diff -uN
Files affected: src/sound.c src/scrollbar-x.c src/scrollbar-msw.c src/scrollbar-gtk.c
src/redisplay-x.c src/redisplay-tty.c src/redisplay-output.c src/redisplay-msw.c
src/redisplay-gtk.c src/nas.c src/md5.c src/keymap.c src/input-method-xlib.c
src/glyphs-widget.c src/extents.c src/editfns.c src/dumper.c src/dialog-x.c src/dgif_lib.c
src/device-x.c src/EmacsShell-sub.c lwlib/xlwmenu.c lwlib/lwlib-Xlw.c
Index: lwlib/lwlib-Xlw.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/lwlib-Xlw.c,v
retrieving revision 1.8.2.2
diff -d -u -r1.8.2.2 lwlib-Xlw.c
--- lwlib/lwlib-Xlw.c	2005/11/26 03:47:33	1.8.2.2
+++ lwlib/lwlib-Xlw.c	2006/06/22 23:33:13
@@ -163,13 +163,13 @@
   XlwScrollBarCallbackStruct *data =
     (XlwScrollBarCallbackStruct *) call_data;
   scroll_event event_data;
-  scrollbar_values *val =
-    (scrollbar_values *) instance->info->val->scrollbar_data;
+  scrollbar_values *val;
   double percent;
 
   if (!instance || widget->core.being_destroyed)
     return;
 
+  val = (scrollbar_values *) instance->info->val->scrollbar_data;
   id = instance->info->id;
 
   percent = (double) (data->value - 1) / (double) (INT_MAX - 1);
Index: lwlib/xlwmenu.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/xlwmenu.c,v
retrieving revision 1.33.2.2
diff -d -u -r1.33.2.2 xlwmenu.c
--- lwlib/xlwmenu.c	2003/02/15 18:57:19	1.33.2.2
+++ lwlib/xlwmenu.c	2006/06/22 23:33:14
@@ -3412,8 +3412,8 @@
   if (!mw->menu.pointer_grabbed)
     {
       XWindowAttributes ret;
-      Window parent,root;
-      Window *waste;
+      Window parent,root = 0UL;
+      Window *waste = NULL;
       unsigned int num_waste;
 
       lw_menu_active = True;
Index: src/EmacsShell-sub.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/EmacsShell-sub.c,v
retrieving revision 1.5.2.2
diff -d -u -r1.5.2.2 EmacsShell-sub.c
--- src/EmacsShell-sub.c	2005/01/31 02:55:01	1.5.2.2
+++ src/EmacsShell-sub.c	2006/06/22 23:33:14
@@ -366,11 +366,11 @@
       for (i = 0; i < w->composite.num_children; i++) {
 	if (XtIsManaged(w->composite.children[i])) {
 	  child = w->composite.children[i];
+	  update_size_hints_internal (w, child->core.width,
+				      child->core.height);
 	  break;
 	}
       }
-
-      update_size_hints_internal (w, child->core.width, child->core.height);
     }
 
   /* call the real ChangeManaged */
Index: src/device-x.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/device-x.c,v
retrieving revision 1.36.2.3
diff -d -u -r1.36.2.3 device-x.c
--- src/device-x.c	2005/01/31 02:55:08	1.36.2.3
+++ src/device-x.c	2006/06/22 23:33:14
@@ -1161,8 +1161,10 @@
      Xlib might just decide to exit().  So we mark the offending
      console for deletion and throw to top level.  */
   if (d)
-    enqueue_magic_eval_event (io_error_delete_device, dev);
-  DEVICE_X_BEING_DELETED (d) = 1;
+    {
+      enqueue_magic_eval_event (io_error_delete_device, dev);
+      DEVICE_X_BEING_DELETED (d) = 1;
+    }
   Fthrow (Qtop_level, Qnil);
 
   return 0; /* not reached */
Index: src/dgif_lib.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/dgif_lib.c,v
retrieving revision 1.12.2.1
diff -d -u -r1.12.2.1 dgif_lib.c
--- src/dgif_lib.c	2004/05/06 22:21:43	1.12.2.1
+++ src/dgif_lib.c	2006/06/22 23:33:14
@@ -366,10 +366,11 @@
 ******************************************************************************/
 int DGifCloseFile(GifFileType *GifFile)
 {
-    GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
+    GifFilePrivateType *Private;
 
     if (GifFile == NULL) return -1;
 
+    Private = (GifFilePrivateType *)GifFile->Private;
     if (!IS_READABLE(Private))
     {
 	/* This file was NOT open for reading: */
@@ -930,7 +931,10 @@
 
     Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType));
     if (Object->Colors == (GifColorType *)NULL)
+      {
+	free (Object);
 	return((ColorMapObject *)NULL);
+      }
 
     Object->ColorCount = ColorCount;
     Object->BitsPerPixel = BitSize(ColorCount);
Index: src/dialog-x.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/dialog-x.c,v
retrieving revision 1.7
diff -d -u -r1.7 dialog-x.c
--- src/dialog-x.c	2001/04/12 18:23:34	1.7
+++ src/dialog-x.c	2006/06/22 23:33:14
@@ -105,7 +105,7 @@
      ourselves. */
 #ifdef EXTERNAL_WIDGET
   /* #### Not sure if this special case is necessary. */
-  if (!FRAME_X_EXTERNAL_WINDOW_P (f) && f)
+  if (f && !FRAME_X_EXTERNAL_WINDOW_P (f))
 #else
   if (f)
 #endif
Index: src/dumper.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/dumper.c,v
retrieving revision 1.2.2.5
diff -d -u -r1.2.2.5 dumper.c
--- src/dumper.c	2005/01/31 02:55:08	1.2.2.5
+++ src/dumper.c	2006/06/22 23:33:14
@@ -566,7 +566,7 @@
   if (imp->description)
     {
       int me = depth++;
-      if (me>65536)
+      if (me>=65536)
 	{
 	  stderr_out ("Backtrace overflow, loop ?\n");
 	  ABORT ();
@@ -601,7 +601,7 @@
     {
       int me = depth++;
       int i;
-      if (me>65536)
+      if (me>=65536)
 	{
 	  stderr_out ("Backtrace overflow, loop ?\n");
 	  ABORT ();
Index: src/editfns.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/editfns.c,v
retrieving revision 1.27.2.4
diff -d -u -r1.27.2.4 editfns.c
--- src/editfns.c	2002/08/20 11:36:52	1.27.2.4
+++ src/editfns.c	2006/06/22 23:33:14
@@ -644,14 +644,17 @@
 	}
       else
 	{
-	  strcpy(path, getenv("HOME")); strncat(path, "/tmp/",
_POSIX_PATH_MAX);
+	  path[5 + _POSIX_PATH_MAX] = '\0';
+	  strncpy(path, getenv("HOME"), 5 + _POSIX_PATH_MAX);
+	  strncat(path, "/tmp/", 5 + _POSIX_PATH_MAX);
 	  if (stat(path, &st) < 0 && errno == ENOENT)
 	    {
 	      int fd;
-	      char warnpath[1+_POSIX_PATH_MAX];
+	      char warnpath[6+_POSIX_PATH_MAX];
 	      mkdir(path, 0700);	/* ignore retvals */
-	      strcpy(warnpath, path);
-	      strncat(warnpath, ".created_by_xemacs", _POSIX_PATH_MAX);
+	      warnpath[_POSIX_PATH_MAX] = '\0';
+	      strncpy(warnpath, path, 5 + _POSIX_PATH_MAX);
+	      strncat(warnpath, ".created_by_xemacs", 5 + _POSIX_PATH_MAX);
 	      if ((fd = open(warnpath, O_WRONLY|O_CREAT, 0644)) > 0)
 		{
 		  write(fd, "XEmacs created this directory because /tmp/<yourname> was
unavailable -- \nPlease check !\n", 89);
Index: src/extents.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/extents.c,v
retrieving revision 1.31.2.4
diff -d -u -r1.31.2.4 extents.c
--- src/extents.c	2005/01/31 02:55:13	1.31.2.4
+++ src/extents.c	2006/06/22 23:33:14
@@ -1175,11 +1175,12 @@
 	      set_extent_start (e, -1);
 	      set_extent_end (e, -1);
 	    }
+
+	  /* But we need to clear all the lists containing extents or
+	     havoc will result. */
+	  extent_list_delete_all (data->extents);
 	}
 
-      /* But we need to clear all the lists containing extents or
-	 havoc will result. */
-      extent_list_delete_all (data->extents);
       soe_invalidate (object);
     }
 }
Index: src/glyphs-widget.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/glyphs-widget.c,v
retrieving revision 1.2.2.2
diff -d -u -r1.2.2.2 glyphs-widget.c
--- src/glyphs-widget.c	2002/11/07 06:04:44	1.2.2.2
+++ src/glyphs-widget.c	2006/06/22 23:33:14
@@ -558,20 +558,20 @@
 				     IMAGE_INSTANCE_WIDGET_FACE (ii),
 				     &w, &h, 0, domain);
 	      /* Adjust the size for borders. */
-	      if (IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
+	      if (width && IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
 		*width = w + 2 * widget_instance_border_width (ii);
-	      if (IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii))
+	      if (height && IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii))
 		*height = h +  2 * widget_instance_border_width (ii);
 	    }
 	}
       /* Finish off with dynamic sizing. */
-      if (!NILP (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii)))
+      if (width && !NILP (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii)))
 	{
 	  dynamic_width = Feval (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii));
 	  if (INTP (dynamic_width))
 	    *width = XINT (dynamic_width);
 	}
-      if (!NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)))
+      if (height && !NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)))
 	{
 	  dynamic_height = Feval (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii));
 	  if (INTP (dynamic_height))
Index: src/input-method-xlib.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/input-method-xlib.c,v
retrieving revision 1.12.2.1
diff -d -u -r1.12.2.1 input-method-xlib.c
--- src/input-method-xlib.c	2005/01/31 02:55:20	1.12.2.1
+++ src/input-method-xlib.c	2006/06/22 23:33:14
@@ -426,13 +426,18 @@
 void
 XIM_SetGeometry (struct frame *f)
 {
-  XIC      xic   = FRAME_X_XIC (f);
-  XIMStyle style = FRAME_X_XIC_STYLE (f);
+  XIC      xic;
+  XIMStyle style;
   XRectangle area;
 
-  if (!xic || !f)
+  if (!f)
     return;
 
+  xic = FRAME_X_XIC (f);
+  if (!xic)
+    return;
+
+  style = FRAME_X_XIC_STYLE (f);
   if (style & XIMStatusArea)
     {
       /* Place Status Area in bottom right corner */
Index: src/keymap.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/keymap.c,v
retrieving revision 1.32.2.4
diff -d -u -r1.32.2.4 keymap.c
--- src/keymap.c	2005/01/31 02:55:20	1.32.2.4
+++ src/keymap.c	2006/06/22 23:33:15
@@ -3663,6 +3663,8 @@
 	      struct key_data *new = xnew_array (struct key_data, size);
 	      memcpy ((void *)new, (const void *)c->keys_so_far,
 		      c->keys_so_far_total_size * sizeof (struct key_data));
+	      xfree (c->keys_so_far);
+	      c->keys_so_far = new;
 	    }
 	  else
 	    XREALLOC_ARRAY (c->keys_so_far, struct key_data, size);
Index: src/md5.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/md5.c,v
retrieving revision 1.9
diff -d -u -r1.9 md5.c
--- src/md5.c	2001/04/12 18:24:01	1.9
+++ src/md5.c	2006/06/22 23:33:15
@@ -581,7 +581,7 @@
       Bufbyte tempbuf[1024];	/* some random amount */
       Lstream_data_count size_in_bytes =
 	Lstream_read (XLSTREAM (instream), tempbuf, sizeof (tempbuf));
-      if (!size_in_bytes)
+      if (size_in_bytes <= 0)
 	break;
 
       /* Process the bytes.  */
Index: src/nas.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/nas.c,v
retrieving revision 1.7.2.2
diff -d -u -r1.7.2.2 nas.c
--- src/nas.c	2002/10/31 15:08:26	1.7.2.2
+++ src/nas.c	2006/06/22 23:33:15
@@ -751,7 +751,7 @@
 /* Stuff taken from wave.c from NAS.  Just like snd files, NAS can't
    read wave data from memory, so these functions do that for us. */
 
-#define Err()		{ return NULL; }
+#define Err()		{ free (wi); return NULL; }
 #define readFourcc(_f)	dread(_f, sizeof(RIFF_FOURCC), 1)
 #define cmpID(_x, _y)							      \
     strncmp((char *) (_x), (char *) (_y), sizeof(RIFF_FOURCC))
Index: src/redisplay-gtk.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/redisplay-gtk.c,v
retrieving revision 1.2.2.3
diff -d -u -r1.2.2.3 redisplay-gtk.c
--- src/redisplay-gtk.c	2005/01/31 02:55:27	1.2.2.3
+++ src/redisplay-gtk.c	2006/06/22 23:33:15
@@ -294,7 +294,7 @@
 			  int cursor_width, int cursor_height)
 {
   struct frame *f = XFRAME (w->frame);
-  Emchar_dynarr *buf = Dynarr_new (Emchar);
+  Emchar_dynarr *buf;
   Lisp_Object window;
 
   struct display_block *db = Dynarr_atp (dl->display_blocks, block);
@@ -326,7 +326,7 @@
 
   if (end < 0)
     end = Dynarr_length (rba);
-  Dynarr_reset (buf);
+  buf = Dynarr_new (Emchar);
 
   while (elt < end)
     {
Index: src/redisplay-msw.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/redisplay-msw.c,v
retrieving revision 1.29.2.2
diff -d -u -r1.29.2.2 redisplay-msw.c
--- src/redisplay-msw.c	2005/01/31 02:55:27	1.29.2.2
+++ src/redisplay-msw.c	2006/06/22 23:33:15
@@ -1,4 +1,4 @@
-/* mswindows output and frame manipulation routines.
+* mswindows output and frame manipulation routines.
    Copyright (C) 1994, 1995 Board of Trustees, University of Illinois.
    Copyright (C) 1994 Lucid, Inc.
    Copyright (C) 1995 Sun Microsystems, Inc.
@@ -1044,7 +1044,7 @@
 			  int cursor_width, int cursor_height)
 {
   struct frame *f = XFRAME (w->frame);
-  Emchar_dynarr *buf = Dynarr_new (Emchar);
+  Emchar_dynarr *buf;
   Lisp_Object window;
 
   struct display_block *db = Dynarr_atp (dl->display_blocks, block);
@@ -1071,7 +1071,7 @@
 
   if (end < 0)
     end = Dynarr_length (rba);
-  Dynarr_reset (buf);
+  buf = Dynarr_new (Emchar);
 
   while (elt < end)
     {
Index: src/redisplay-output.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/redisplay-output.c,v
retrieving revision 1.12.2.4
diff -d -u -r1.12.2.4 redisplay-output.c
--- src/redisplay-output.c	2005/01/31 02:55:28	1.12.2.4
+++ src/redisplay-output.c	2006/06/22 23:33:15
@@ -1317,7 +1317,7 @@
 {
   Lisp_Image_Instance *p = XIMAGE_INSTANCE (image_instance);
   Lisp_Object rest, window = DOMAIN_WINDOW (domain);
-  Emchar_dynarr *buf = Dynarr_new (Emchar);
+  Emchar_dynarr *buf;
   struct window *w = XWINDOW (window);
   struct device *d = DOMAIN_XDEVICE (domain);
   int layout_height, layout_width;
@@ -1333,6 +1333,8 @@
   /* This makes the glyph area fit into the display area. */
   if (!redisplay_normalize_glyph_area (db, dga))
     return;
+
+  buf = Dynarr_new (Emchar);
 
   /* Highly dodgy optimization. We want to only output the whole
      layout if we really have to. */
Index: src/redisplay-tty.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/redisplay-tty.c,v
retrieving revision 1.16.2.2
diff -d -u -r1.16.2.2 redisplay-tty.c
--- src/redisplay-tty.c	2005/11/28 02:10:20	1.16.2.2
+++ src/redisplay-tty.c	2006/06/22 23:33:15
@@ -196,7 +196,7 @@
 			  int cursor_height)
 {
   struct frame *f = XFRAME (w->frame);
-  Emchar_dynarr *buf = Dynarr_new (Emchar);
+  Emchar_dynarr *buf;
 
   struct display_block *db = Dynarr_atp (dl->display_blocks, block);
   rune_dynarr *rba = db->runes;
@@ -222,7 +222,7 @@
   if (end < 0)
     end = Dynarr_length (rba);
 
-  Dynarr_reset (buf);
+  buf = Dynarr_new (Emchar);
 
   while (elt < end && Dynarr_atp (rba, elt)->xpos < start_pixpos)
     {
Index: src/redisplay-x.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/redisplay-x.c,v
retrieving revision 1.25.2.5
diff -d -u -r1.25.2.5 redisplay-x.c
--- src/redisplay-x.c	2005/01/31 02:55:28	1.25.2.5
+++ src/redisplay-x.c	2006/06/22 23:33:15
@@ -318,7 +318,7 @@
 			int cursor_width, int cursor_height)
 {
   struct frame *f = XFRAME (w->frame);
-  Emchar_dynarr *buf = Dynarr_new (Emchar);
+  Emchar_dynarr *buf;
   Lisp_Object window;
 
   struct display_block *db = Dynarr_atp (dl->display_blocks, block);
@@ -345,7 +345,7 @@
 
   if (end < 0)
     end = Dynarr_length (rba);
-  Dynarr_reset (buf);
+  buf = Dynarr_new (Emchar);
 
   while (elt < end)
     {
Index: src/scrollbar-gtk.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/scrollbar-gtk.c,v
retrieving revision 1.2.2.4
diff -d -u -r1.2.2.4 scrollbar-gtk.c
--- src/scrollbar-gtk.c	2005/01/31 02:55:30	1.2.2.4
+++ src/scrollbar-gtk.c	2006/06/22 23:33:15
@@ -57,14 +57,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);
+      xfree (instance->scrollbar_data);
+    }
 }
 
 /* A device method. */
Index: src/scrollbar-msw.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/scrollbar-msw.c,v
retrieving revision 1.11.2.5
diff -d -u -r1.11.2.5 scrollbar-msw.c
--- src/scrollbar-msw.c	2005/01/31 02:55:31	1.11.2.5
+++ src/scrollbar-msw.c	2006/06/22 23:33:15
@@ -83,9 +83,11 @@
 static void
 mswindows_free_scrollbar_instance (struct scrollbar_instance *sb)
 {
-  DestroyWindow (SCROLLBAR_MSW_HANDLE (sb));
   if (sb->scrollbar_data)
-    xfree (sb->scrollbar_data);
+    {
+      DestroyWindow (SCROLLBAR_MSW_HANDLE (sb));
+      xfree (sb->scrollbar_data);
+    }
 }
 
 static void
Index: src/scrollbar-x.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/scrollbar-x.c,v
retrieving revision 1.17.2.1
diff -d -u -r1.17.2.1 scrollbar-x.c
--- src/scrollbar-x.c	2005/01/31 02:55:31	1.17.2.1
+++ src/scrollbar-x.c	2006/06/22 23:33:15
@@ -71,19 +71,21 @@
 static void
 x_free_scrollbar_instance (struct scrollbar_instance *instance)
 {
-  if (SCROLLBAR_X_NAME (instance))
-    xfree (SCROLLBAR_X_NAME (instance));
-
-  if (SCROLLBAR_X_WIDGET (instance))
+  if (instance->scrollbar_data)
     {
-      if (XtIsManaged (SCROLLBAR_X_WIDGET (instance)))
-	XtUnmanageChild (SCROLLBAR_X_WIDGET (instance));
+      if (SCROLLBAR_X_NAME (instance))
+	xfree (SCROLLBAR_X_NAME (instance));
 
-      lw_destroy_all_widgets (SCROLLBAR_X_ID (instance));
-    }
+      if (SCROLLBAR_X_WIDGET (instance))
+	{
+	  if (XtIsManaged (SCROLLBAR_X_WIDGET (instance)))
+	    XtUnmanageChild (SCROLLBAR_X_WIDGET (instance));
 
-  if (instance->scrollbar_data)
-    xfree (instance->scrollbar_data);
+	  lw_destroy_all_widgets (SCROLLBAR_X_ID (instance));
+	}
+
+      xfree (instance->scrollbar_data);
+    }
 }
 
 /* A device method. */
Index: src/sound.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/sound.c,v
retrieving revision 1.12
diff -d -u -r1.12 sound.c
--- src/sound.c	2001/04/12 18:24:19	1.12
+++ src/sound.c	2006/06/22 23:33:15
@@ -517,7 +517,7 @@
 		DEVICE_ON_CONSOLE_P (d) = 0;
 	      else
 		{
-		  char hn [255];
+		  char *hn = alloca_array (char, strlen (h->h_name) + 1);
 		  struct hostent *l;
 		  strcpy (hn, h->h_name);
 		  l = gethostbyname (localname);
-- 
Jerry James, Assistant Professor        james(a)xemacs.org
Computer Science Department             
http://www.cs.usu.edu/~jerry/
Utah State University