Hi

Vim-7.2.315 is leaking memory whenever error E669 happens:

==4880== 18 bytes in 3 blocks are definitely lost in loss record 116 of 363
==4880==    at 0x4024F3C: malloc (vg_replace_malloc.c:195)
==4880==    by 0x810E187: lalloc (misc2.c:866)
==4880==    by 0x810E091: alloc (misc2.c:765)
==4880==    by 0x810E5FA: vim_strnsave (misc2.c:1195)
==4880==    by 0x819F4BC: syn_check_group (syntax.c:8621)
==4880==    by 0x819BD0A: do_highlight (syntax.c:6751)
==4880==    by 0x80A7BD0: ex_highlight (ex_docmd.c:6233)
==4880==    by 0x80A2098: do_one_cmd (ex_docmd.c:2629)
==4880==    by 0x809F971: do_cmdline (ex_docmd.c:1098)
==4880==    by 0x80883B8: ex_execute (eval.c:19592)
==4880==    by 0x80A2098: do_one_cmd (ex_docmd.c:2629)
==4880==    by 0x809F971: do_cmdline (ex_docmd.c:1098)
==4880==    by 0x8123C34: nv_colon (normal.c:5224)
==4880==    by 0x811D631: normal_cmd (normal.c:1188)
==4880==    by 0x80E12BD: main_loop (main.c:1204)
==4880==    by 0x80E0DB4: main (main.c:948)

Leak happens when trying to add a highlight group with
non-printable characters.  Following command for example
will cause a leak:

  :exe "hi \<c-v>\<c-a> term=bold"

Attached patch fixes it.

Cheers
-- Dominique

-- 
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
Index: syntax.c
===================================================================
RCS file: /cvsroot/vim/vim7/src/syntax.c,v
retrieving revision 1.83
diff -c -r1.83 syntax.c
*** syntax.c	17 May 2009 11:32:26 -0000	1.83
--- syntax.c	12 Dec 2009 22:43:04 -0000
***************
*** 206,212 ****
  static int current_attr = 0;	    /* attr of current syntax word */
  #ifdef FEAT_EVAL
  static int current_id = 0;	    /* ID of current char for syn_get_id() */
! static int current_trans_id = 0;    /* idem, transparancy removed */
  #endif
  
  typedef struct syn_cluster_S
--- 206,212 ----
  static int current_attr = 0;	    /* attr of current syntax word */
  #ifdef FEAT_EVAL
  static int current_id = 0;	    /* ID of current char for syn_get_id() */
! static int current_trans_id = 0;    /* idem, transparency removed */
  #endif
  
  typedef struct syn_cluster_S
***************
*** 282,288 ****
      int		si_idx;			/* index of syntax pattern or
  					   KEYWORD_IDX */
      int		si_id;			/* highlight group ID for keywords */
!     int		si_trans_id;		/* idem, transparancy removed */
      int		si_m_lnum;		/* lnum of the match */
      int		si_m_startcol;		/* starting column of the match */
      lpos_T	si_m_endpos;		/* just after end posn of the match */
--- 282,288 ----
      int		si_idx;			/* index of syntax pattern or
  					   KEYWORD_IDX */
      int		si_id;			/* highlight group ID for keywords */
!     int		si_trans_id;		/* idem, transparency removed */
      int		si_m_lnum;		/* lnum of the match */
      int		si_m_startcol;		/* starting column of the match */
      lpos_T	si_m_endpos;		/* just after end posn of the match */
***************
*** 1274,1280 ****
  	dist = syn_buf->b_ml.ml_line_count / (syn_buf->b_sst_len - Rows) + 1;
  
      /*
!      * Go throught the list to find the "tick" for the oldest entry that can
       * be removed.  Set "above" when the "tick" for the oldest entry is above
       * "b_sst_lasttick" (the display tick wraps around).
       */
--- 1274,1280 ----
  	dist = syn_buf->b_ml.ml_line_count / (syn_buf->b_sst_len - Rows) + 1;
  
      /*
!      * Go through the list to find the "tick" for the oldest entry that can
       * be removed.  Set "above" when the "tick" for the oldest entry is above
       * "b_sst_lasttick" (the display tick wraps around).
       */
***************
*** 6108,6114 ****
      win_T	*wp;
      long	lnum;
      colnr_T	col;
!     int		trans;	     /* remove transparancy */
      int		*spellp;     /* return: can do spell checking */
      int		keep_state;  /* keep state of char at "col" */
  {
--- 6108,6114 ----
      win_T	*wp;
      long	lnum;
      colnr_T	col;
!     int		trans;	     /* remove transparency */
      int		*spellp;     /* return: can do spell checking */
      int		keep_state;  /* keep state of char at "col" */
  {
***************
*** 7523,7529 ****
  #if defined(FEAT_GUI) || defined(PROTO)
  /*
   * Set the normal foreground and background colors according to the "Normal"
!  * highlighighting group.  For X11 also set "Menu", "Scrollbar", and
   * "Tooltip" colors.
   */
      void
--- 7523,7529 ----
  #if defined(FEAT_GUI) || defined(PROTO)
  /*
   * Set the normal foreground and background colors according to the "Normal"
!  * highlighting group.  For X11 also set "Menu", "Scrollbar", and
   * "Tooltip" colors.
   */
      void
***************
*** 8647,8652 ****
--- 8647,8653 ----
  	if (!vim_isprintc(*p))
  	{
  	    EMSG(_("E669: Unprintable character in group name"));
+ 	    vim_free(name);
  	    return 0;
  	}
  	else if (!ASCII_ISALNUM(*p) && *p != '_')

Raspunde prin e-mail lui