Karsten Hopp f942a4
To: vim_dev@googlegroups.com
Karsten Hopp f942a4
Subject: Patch 7.3.073
Karsten Hopp f942a4
Fcc: outbox
Karsten Hopp f942a4
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp f942a4
Mime-Version: 1.0
Karsten Hopp f942a4
Content-Type: text/plain; charset=UTF-8
Karsten Hopp f942a4
Content-Transfer-Encoding: 8bit
Karsten Hopp f942a4
------------
Karsten Hopp f942a4
Karsten Hopp f942a4
Patch 7.3.073
Karsten Hopp f942a4
Problem:    Double free memory when netbeans command follows DETACH.
Karsten Hopp f942a4
Solution:   Only free the node when owned. (Xavier de Gaye)
Karsten Hopp f942a4
Files:	    src/netbeans.c
Karsten Hopp f942a4
Karsten Hopp f942a4
Karsten Hopp f942a4
*** ../vim-7.3.072/src/netbeans.c	2010-11-16 15:48:57.000000000 +0100
Karsten Hopp f942a4
--- src/netbeans.c	2010-12-02 16:59:11.000000000 +0100
Karsten Hopp f942a4
***************
Karsten Hopp f942a4
*** 643,648 ****
Karsten Hopp f942a4
--- 643,649 ----
Karsten Hopp f942a4
  {
Karsten Hopp f942a4
      char_u	*p;
Karsten Hopp f942a4
      queue_T	*node;
Karsten Hopp f942a4
+     int		own_node;
Karsten Hopp f942a4
  
Karsten Hopp f942a4
      while (head.next != NULL && head.next != &head)
Karsten Hopp f942a4
      {
Karsten Hopp f942a4
***************
Karsten Hopp f942a4
*** 681,700 ****
Karsten Hopp f942a4
  	    *p++ = NUL;
Karsten Hopp f942a4
  	    if (*p == NUL)
Karsten Hopp f942a4
  	    {
Karsten Hopp f942a4
  		head.next = node->next;
Karsten Hopp f942a4
  		node->next->prev = node->prev;
Karsten Hopp f942a4
  	    }
Karsten Hopp f942a4
  
Karsten Hopp f942a4
  	    /* now, parse and execute the commands */
Karsten Hopp f942a4
  	    nb_parse_cmd(node->buffer);
Karsten Hopp f942a4
  
Karsten Hopp f942a4
! 	    if (*p == NUL)
Karsten Hopp f942a4
  	    {
Karsten Hopp f942a4
  		/* buffer finished, dispose of the node and buffer */
Karsten Hopp f942a4
  		vim_free(node->buffer);
Karsten Hopp f942a4
  		vim_free(node);
Karsten Hopp f942a4
  	    }
Karsten Hopp f942a4
! 	    else
Karsten Hopp f942a4
  	    {
Karsten Hopp f942a4
  		/* more follows, move to the start */
Karsten Hopp f942a4
  		STRMOVE(node->buffer, p);
Karsten Hopp f942a4
--- 682,706 ----
Karsten Hopp f942a4
  	    *p++ = NUL;
Karsten Hopp f942a4
  	    if (*p == NUL)
Karsten Hopp f942a4
  	    {
Karsten Hopp f942a4
+ 		own_node = TRUE;
Karsten Hopp f942a4
  		head.next = node->next;
Karsten Hopp f942a4
  		node->next->prev = node->prev;
Karsten Hopp f942a4
  	    }
Karsten Hopp f942a4
+ 	    else
Karsten Hopp f942a4
+ 		own_node = FALSE;
Karsten Hopp f942a4
  
Karsten Hopp f942a4
  	    /* now, parse and execute the commands */
Karsten Hopp f942a4
  	    nb_parse_cmd(node->buffer);
Karsten Hopp f942a4
  
Karsten Hopp f942a4
! 	    if (own_node)
Karsten Hopp f942a4
  	    {
Karsten Hopp f942a4
  		/* buffer finished, dispose of the node and buffer */
Karsten Hopp f942a4
  		vim_free(node->buffer);
Karsten Hopp f942a4
  		vim_free(node);
Karsten Hopp f942a4
  	    }
Karsten Hopp f942a4
! 	    /* Check that "head" wasn't changed under our fingers, e.g. when a
Karsten Hopp f942a4
! 	     * DETACH command was handled. */
Karsten Hopp f942a4
! 	    else if (head.next == node)
Karsten Hopp f942a4
  	    {
Karsten Hopp f942a4
  		/* more follows, move to the start */
Karsten Hopp f942a4
  		STRMOVE(node->buffer, p);
Karsten Hopp f942a4
*** ../vim-7.3.072/src/version.c	2010-12-02 16:01:23.000000000 +0100
Karsten Hopp f942a4
--- src/version.c	2010-12-02 17:00:29.000000000 +0100
Karsten Hopp f942a4
***************
Karsten Hopp f942a4
*** 716,717 ****
Karsten Hopp f942a4
--- 716,719 ----
Karsten Hopp f942a4
  {   /* Add new patch number below this line */
Karsten Hopp f942a4
+ /**/
Karsten Hopp f942a4
+     73,
Karsten Hopp f942a4
  /**/
Karsten Hopp f942a4
Karsten Hopp f942a4
-- 
Karsten Hopp f942a4
If the Universe is constantly expanding, why can't I ever find a parking space?
Karsten Hopp f942a4
Karsten Hopp f942a4
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp f942a4
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp f942a4
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp f942a4
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///