Karsten Hopp ecf86c
To: vim-dev@vim.org
Karsten Hopp ecf86c
Subject: Patch 7.1.318
Karsten Hopp ecf86c
Fcc: outbox
Karsten Hopp ecf86c
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp ecf86c
Mime-Version: 1.0
Karsten Hopp ecf86c
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp ecf86c
Content-Transfer-Encoding: 8bit
Karsten Hopp ecf86c
------------
Karsten Hopp ecf86c
Karsten Hopp ecf86c
Patch 7.1.318
Karsten Hopp ecf86c
Problem:    Memory leak when closing xsmp connection.  Crash on exit when
Karsten Hopp ecf86c
	    using Lesstif.
Karsten Hopp ecf86c
Solution:   Don't close the X display to work around a Lesstif bug.  Free
Karsten Hopp ecf86c
	    clientid.  Also fix a leak for Motif and Athena. (Dominique Pelle)
Karsten Hopp ecf86c
Files:	    src/gui_x11.c, src/os_unix.c
Karsten Hopp ecf86c
Karsten Hopp ecf86c
Karsten Hopp ecf86c
*** ../vim-7.1.317/src/gui_x11.c	Thu May 10 21:11:45 2007
Karsten Hopp ecf86c
--- src/gui_x11.c	Sun Jun  8 17:13:45 2008
Karsten Hopp ecf86c
***************
Karsten Hopp ecf86c
*** 1538,1545 ****
Karsten Hopp ecf86c
--- 1538,1548 ----
Karsten Hopp ecf86c
      attr.depth = DefaultDepthOfScreen(scr);
Karsten Hopp ecf86c
  
Karsten Hopp ecf86c
      if (!icon)
Karsten Hopp ecf86c
+     {
Karsten Hopp ecf86c
  	XpmCreatePixmapFromData(dsp, root_window, magick, &icon,
Karsten Hopp ecf86c
  							   &icon_mask, &attr);
Karsten Hopp ecf86c
+ 	XpmFreeAttributes(&attr);
Karsten Hopp ecf86c
+     }
Karsten Hopp ecf86c
  
Karsten Hopp ecf86c
  # ifdef FEAT_GUI_ATHENA
Karsten Hopp ecf86c
      XtVaSetValues(vimShell, XtNiconPixmap, icon, XtNiconMask, icon_mask, NULL);
Karsten Hopp ecf86c
*** ../vim-7.1.317/src/os_unix.c	Wed May  7 19:05:55 2008
Karsten Hopp ecf86c
--- src/os_unix.c	Tue Jun 17 21:03:54 2008
Karsten Hopp ecf86c
***************
Karsten Hopp ecf86c
*** 209,214 ****
Karsten Hopp ecf86c
--- 209,215 ----
Karsten Hopp ecf86c
  {
Karsten Hopp ecf86c
      SmcConn smcconn;	    /* The SM connection ID */
Karsten Hopp ecf86c
      IceConn iceconn;	    /* The ICE connection ID */
Karsten Hopp ecf86c
+     char *clientid;         /* The client ID for the current smc session */
Karsten Hopp ecf86c
      Bool save_yourself;     /* If we're in the middle of a save_yourself */
Karsten Hopp ecf86c
      Bool shutdown;	    /* If we're in shutdown mode */
Karsten Hopp ecf86c
  } xsmp_config_T;
Karsten Hopp ecf86c
***************
Karsten Hopp ecf86c
*** 2887,2902 ****
Karsten Hopp ecf86c
      if (clip_plus.owned)
Karsten Hopp ecf86c
  	clip_lose_selection(&clip_plus);
Karsten Hopp ecf86c
  # endif
Karsten Hopp ecf86c
! # if (defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)) || defined(PROTO)
Karsten Hopp ecf86c
      if (xterm_Shell != (Widget)0)
Karsten Hopp ecf86c
  	XtDestroyWidget(xterm_Shell);
Karsten Hopp ecf86c
      if (xterm_dpy != NULL)
Karsten Hopp ecf86c
  	XtCloseDisplay(xterm_dpy);
Karsten Hopp ecf86c
      if (app_context != (XtAppContext)NULL)
Karsten Hopp ecf86c
  	XtDestroyApplicationContext(app_context);
Karsten Hopp ecf86c
  # endif
Karsten Hopp ecf86c
  # ifdef FEAT_X11
Karsten Hopp ecf86c
!     if (x11_display != NULL && x11_display != xterm_dpy)
Karsten Hopp ecf86c
  	XCloseDisplay(x11_display);
Karsten Hopp ecf86c
  # endif
Karsten Hopp ecf86c
  # if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
Karsten Hopp ecf86c
--- 2893,2920 ----
Karsten Hopp ecf86c
      if (clip_plus.owned)
Karsten Hopp ecf86c
  	clip_lose_selection(&clip_plus);
Karsten Hopp ecf86c
  # endif
Karsten Hopp ecf86c
! # if defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)
Karsten Hopp ecf86c
      if (xterm_Shell != (Widget)0)
Karsten Hopp ecf86c
  	XtDestroyWidget(xterm_Shell);
Karsten Hopp ecf86c
+ #  ifndef LESSTIF_VERSION
Karsten Hopp ecf86c
+     /* Lesstif crashes here, lose some memory */
Karsten Hopp ecf86c
      if (xterm_dpy != NULL)
Karsten Hopp ecf86c
  	XtCloseDisplay(xterm_dpy);
Karsten Hopp ecf86c
      if (app_context != (XtAppContext)NULL)
Karsten Hopp ecf86c
+     {
Karsten Hopp ecf86c
  	XtDestroyApplicationContext(app_context);
Karsten Hopp ecf86c
+ #   ifdef FEAT_X11
Karsten Hopp ecf86c
+ 	x11_display = NULL; /* freed by XtDestroyApplicationContext() */
Karsten Hopp ecf86c
+ #   endif
Karsten Hopp ecf86c
+     }
Karsten Hopp ecf86c
+ #  endif
Karsten Hopp ecf86c
  # endif
Karsten Hopp ecf86c
  # ifdef FEAT_X11
Karsten Hopp ecf86c
!     if (x11_display != NULL
Karsten Hopp ecf86c
! #  ifdef FEAT_XCLIPBOARD
Karsten Hopp ecf86c
! 	    && x11_display != xterm_dpy
Karsten Hopp ecf86c
! #  endif
Karsten Hopp ecf86c
! 	    )
Karsten Hopp ecf86c
  	XCloseDisplay(x11_display);
Karsten Hopp ecf86c
  # endif
Karsten Hopp ecf86c
  # if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
Karsten Hopp ecf86c
***************
Karsten Hopp ecf86c
*** 6290,6311 ****
Karsten Hopp ecf86c
      }
Karsten Hopp ecf86c
      if (xterm_dpy != NULL)
Karsten Hopp ecf86c
      {
Karsten Hopp ecf86c
! #if 0
Karsten Hopp ecf86c
  	/* Lesstif and Solaris crash here, lose some memory */
Karsten Hopp ecf86c
  	XtCloseDisplay(xterm_dpy);
Karsten Hopp ecf86c
! #endif
Karsten Hopp ecf86c
  	if (x11_display == xterm_dpy)
Karsten Hopp ecf86c
  	    x11_display = NULL;
Karsten Hopp ecf86c
  	xterm_dpy = NULL;
Karsten Hopp ecf86c
      }
Karsten Hopp ecf86c
! #if 0
Karsten Hopp ecf86c
      if (app_context != (XtAppContext)NULL)
Karsten Hopp ecf86c
      {
Karsten Hopp ecf86c
  	/* Lesstif and Solaris crash here, lose some memory */
Karsten Hopp ecf86c
  	XtDestroyApplicationContext(app_context);
Karsten Hopp ecf86c
  	app_context = (XtAppContext)NULL;
Karsten Hopp ecf86c
      }
Karsten Hopp ecf86c
! #endif
Karsten Hopp ecf86c
  }
Karsten Hopp ecf86c
  # endif
Karsten Hopp ecf86c
  
Karsten Hopp ecf86c
--- 6308,6329 ----
Karsten Hopp ecf86c
      }
Karsten Hopp ecf86c
      if (xterm_dpy != NULL)
Karsten Hopp ecf86c
      {
Karsten Hopp ecf86c
! #  if 0
Karsten Hopp ecf86c
  	/* Lesstif and Solaris crash here, lose some memory */
Karsten Hopp ecf86c
  	XtCloseDisplay(xterm_dpy);
Karsten Hopp ecf86c
! #  endif
Karsten Hopp ecf86c
  	if (x11_display == xterm_dpy)
Karsten Hopp ecf86c
  	    x11_display = NULL;
Karsten Hopp ecf86c
  	xterm_dpy = NULL;
Karsten Hopp ecf86c
      }
Karsten Hopp ecf86c
! #  if 0
Karsten Hopp ecf86c
      if (app_context != (XtAppContext)NULL)
Karsten Hopp ecf86c
      {
Karsten Hopp ecf86c
  	/* Lesstif and Solaris crash here, lose some memory */
Karsten Hopp ecf86c
  	XtDestroyApplicationContext(app_context);
Karsten Hopp ecf86c
  	app_context = (XtAppContext)NULL;
Karsten Hopp ecf86c
      }
Karsten Hopp ecf86c
! #  endif
Karsten Hopp ecf86c
  }
Karsten Hopp ecf86c
  # endif
Karsten Hopp ecf86c
  
Karsten Hopp ecf86c
***************
Karsten Hopp ecf86c
*** 6557,6563 ****
Karsten Hopp ecf86c
  xsmp_init(void)
Karsten Hopp ecf86c
  {
Karsten Hopp ecf86c
      char		errorstring[80];
Karsten Hopp ecf86c
-     char		*clientid;
Karsten Hopp ecf86c
      SmcCallbacks	smcallbacks;
Karsten Hopp ecf86c
  #if 0
Karsten Hopp ecf86c
      SmPropValue		smname;
Karsten Hopp ecf86c
--- 6575,6580 ----
Karsten Hopp ecf86c
***************
Karsten Hopp ecf86c
*** 6599,6605 ****
Karsten Hopp ecf86c
  		     | SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask,
Karsten Hopp ecf86c
  	    &smcallbacks,
Karsten Hopp ecf86c
  	    NULL,
Karsten Hopp ecf86c
! 	    &clientid,
Karsten Hopp ecf86c
  	    sizeof(errorstring),
Karsten Hopp ecf86c
  	    errorstring);
Karsten Hopp ecf86c
      if (xsmp.smcconn == NULL)
Karsten Hopp ecf86c
--- 6616,6622 ----
Karsten Hopp ecf86c
  		     | SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask,
Karsten Hopp ecf86c
  	    &smcallbacks,
Karsten Hopp ecf86c
  	    NULL,
Karsten Hopp ecf86c
! 	    &xsmp.clientid,
Karsten Hopp ecf86c
  	    sizeof(errorstring),
Karsten Hopp ecf86c
  	    errorstring);
Karsten Hopp ecf86c
      if (xsmp.smcconn == NULL)
Karsten Hopp ecf86c
***************
Karsten Hopp ecf86c
*** 6638,6643 ****
Karsten Hopp ecf86c
--- 6655,6662 ----
Karsten Hopp ecf86c
      if (xsmp_icefd != -1)
Karsten Hopp ecf86c
      {
Karsten Hopp ecf86c
  	SmcCloseConnection(xsmp.smcconn, 0, NULL);
Karsten Hopp ecf86c
+ 	vim_free(xsmp.clientid);
Karsten Hopp ecf86c
+ 	xsmp.clientid = NULL;
Karsten Hopp ecf86c
  	xsmp_icefd = -1;
Karsten Hopp ecf86c
      }
Karsten Hopp ecf86c
  }
Karsten Hopp ecf86c
*** ../vim-7.1.317/src/version.c	Fri Jun 20 11:39:04 2008
Karsten Hopp ecf86c
--- src/version.c	Fri Jun 20 11:56:09 2008
Karsten Hopp ecf86c
***************
Karsten Hopp ecf86c
*** 668,669 ****
Karsten Hopp ecf86c
--- 673,676 ----
Karsten Hopp ecf86c
  {   /* Add new patch number below this line */
Karsten Hopp ecf86c
+ /**/
Karsten Hopp ecf86c
+     318,
Karsten Hopp ecf86c
  /**/
Karsten Hopp ecf86c
Karsten Hopp ecf86c
-- 
Karsten Hopp ecf86c
hundred-and-one symptoms of being an internet addict:
Karsten Hopp ecf86c
44. Your friends no longer send you e-mail...they just log on to your IRC
Karsten Hopp ecf86c
    channel.
Karsten Hopp ecf86c
Karsten Hopp ecf86c
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp ecf86c
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp ecf86c
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp ecf86c
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///