Karsten Hopp bdba8b
To: vim-dev@vim.org
Karsten Hopp bdba8b
Subject: Patch 7.0.153
Karsten Hopp bdba8b
Fcc: outbox
Karsten Hopp bdba8b
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp bdba8b
Mime-Version: 1.0
Karsten Hopp bdba8b
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp bdba8b
Content-Transfer-Encoding: 8bit
Karsten Hopp bdba8b
------------
Karsten Hopp bdba8b
Karsten Hopp bdba8b
Patch 7.0.153
Karsten Hopp bdba8b
Problem:    When using cscope and opening the temp file fails Vim crashes.
Karsten Hopp bdba8b
	    (Kaya Bekiroglu)
Karsten Hopp bdba8b
Solution:   Check for NULL pointer returned from mch_open().
Karsten Hopp bdba8b
Files:	    src/if_cscope.c
Karsten Hopp bdba8b
Karsten Hopp bdba8b
Karsten Hopp bdba8b
*** ../vim-7.0.152/src/if_cscope.c	Tue Aug 29 17:28:56 2006
Karsten Hopp bdba8b
--- src/if_cscope.c	Mon Oct 30 22:26:01 2006
Karsten Hopp bdba8b
***************
Karsten Hopp bdba8b
*** 1100,1137 ****
Karsten Hopp bdba8b
      if (qfpos != NULL && *qfpos != '0' && totmatches > 0)
Karsten Hopp bdba8b
      {
Karsten Hopp bdba8b
  	/* fill error list */
Karsten Hopp bdba8b
! 	FILE *f;
Karsten Hopp bdba8b
! 	char_u *tmp = vim_tempname('c');
Karsten Hopp bdba8b
  	qf_info_T   *qi = NULL;
Karsten Hopp bdba8b
  	win_T	    *wp = NULL;
Karsten Hopp bdba8b
  
Karsten Hopp bdba8b
  	f = mch_fopen((char *)tmp, "w");
Karsten Hopp bdba8b
! 	cs_file_results(f, nummatches);
Karsten Hopp bdba8b
! 	fclose(f);
Karsten Hopp bdba8b
! 	if (use_ll)	    /* Use location list */
Karsten Hopp bdba8b
! 	    wp = curwin;
Karsten Hopp bdba8b
! 	/* '-' starts a new error list */
Karsten Hopp bdba8b
! 	if (qf_init(wp, tmp, (char_u *)"%f%*\\t%l%*\\t%m", *qfpos == '-') > 0)
Karsten Hopp bdba8b
  	{
Karsten Hopp bdba8b
! # ifdef FEAT_WINDOWS
Karsten Hopp bdba8b
! 	    if (postponed_split != 0)
Karsten Hopp bdba8b
  	    {
Karsten Hopp bdba8b
! 		win_split(postponed_split > 0 ? postponed_split : 0,
Karsten Hopp bdba8b
  						       postponed_split_flags);
Karsten Hopp bdba8b
  #  ifdef FEAT_SCROLLBIND
Karsten Hopp bdba8b
! 		curwin->w_p_scb = FALSE;
Karsten Hopp bdba8b
  #  endif
Karsten Hopp bdba8b
! 		postponed_split = 0;
Karsten Hopp bdba8b
! 	    }
Karsten Hopp bdba8b
  # endif
Karsten Hopp bdba8b
! 	    if (use_ll)
Karsten Hopp bdba8b
! 		/*
Karsten Hopp bdba8b
! 		 * In the location list window, use the displayed location
Karsten Hopp bdba8b
! 		 * list. Otherwise, use the location list for the window.
Karsten Hopp bdba8b
! 		 */
Karsten Hopp bdba8b
! 		qi = (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL) ?
Karsten Hopp bdba8b
! 				    wp->w_llist_ref : wp->w_llist;
Karsten Hopp bdba8b
! 	    qf_jump(qi, 0, 0, forceit);
Karsten Hopp bdba8b
  	}
Karsten Hopp bdba8b
  	mch_remove(tmp);
Karsten Hopp bdba8b
  	vim_free(tmp);
Karsten Hopp bdba8b
--- 1100,1143 ----
Karsten Hopp bdba8b
      if (qfpos != NULL && *qfpos != '0' && totmatches > 0)
Karsten Hopp bdba8b
      {
Karsten Hopp bdba8b
  	/* fill error list */
Karsten Hopp bdba8b
! 	FILE	    *f;
Karsten Hopp bdba8b
! 	char_u	    *tmp = vim_tempname('c');
Karsten Hopp bdba8b
  	qf_info_T   *qi = NULL;
Karsten Hopp bdba8b
  	win_T	    *wp = NULL;
Karsten Hopp bdba8b
  
Karsten Hopp bdba8b
  	f = mch_fopen((char *)tmp, "w");
Karsten Hopp bdba8b
! 	if (f == NULL)
Karsten Hopp bdba8b
! 	    EMSG2(_(e_notopen), tmp);
Karsten Hopp bdba8b
! 	else
Karsten Hopp bdba8b
  	{
Karsten Hopp bdba8b
! 	    cs_file_results(f, nummatches);
Karsten Hopp bdba8b
! 	    fclose(f);
Karsten Hopp bdba8b
! 	    if (use_ll)	    /* Use location list */
Karsten Hopp bdba8b
! 		wp = curwin;
Karsten Hopp bdba8b
! 	    /* '-' starts a new error list */
Karsten Hopp bdba8b
! 	    if (qf_init(wp, tmp, (char_u *)"%f%*\\t%l%*\\t%m",
Karsten Hopp bdba8b
! 							   *qfpos == '-') > 0)
Karsten Hopp bdba8b
  	    {
Karsten Hopp bdba8b
! # ifdef FEAT_WINDOWS
Karsten Hopp bdba8b
! 		if (postponed_split != 0)
Karsten Hopp bdba8b
! 		{
Karsten Hopp bdba8b
! 		    win_split(postponed_split > 0 ? postponed_split : 0,
Karsten Hopp bdba8b
  						       postponed_split_flags);
Karsten Hopp bdba8b
  #  ifdef FEAT_SCROLLBIND
Karsten Hopp bdba8b
! 		    curwin->w_p_scb = FALSE;
Karsten Hopp bdba8b
  #  endif
Karsten Hopp bdba8b
! 		    postponed_split = 0;
Karsten Hopp bdba8b
! 		}
Karsten Hopp bdba8b
  # endif
Karsten Hopp bdba8b
! 		if (use_ll)
Karsten Hopp bdba8b
! 		    /*
Karsten Hopp bdba8b
! 		     * In the location list window, use the displayed location
Karsten Hopp bdba8b
! 		     * list. Otherwise, use the location list for the window.
Karsten Hopp bdba8b
! 		     */
Karsten Hopp bdba8b
! 		    qi = (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL)
Karsten Hopp bdba8b
! 			?  wp->w_llist_ref : wp->w_llist;
Karsten Hopp bdba8b
! 		qf_jump(qi, 0, 0, forceit);
Karsten Hopp bdba8b
! 	    }
Karsten Hopp bdba8b
  	}
Karsten Hopp bdba8b
  	mch_remove(tmp);
Karsten Hopp bdba8b
  	vim_free(tmp);
Karsten Hopp bdba8b
***************
Karsten Hopp bdba8b
*** 1723,1729 ****
Karsten Hopp bdba8b
  	       continue;
Karsten Hopp bdba8b
  
Karsten Hopp bdba8b
  	   context = (char *)alloc((unsigned)strlen(cntx)+5);
Karsten Hopp bdba8b
! 	   if (context==NULL)
Karsten Hopp bdba8b
  	       continue;
Karsten Hopp bdba8b
  
Karsten Hopp bdba8b
  	   if (strcmp(cntx, "<global>")==0)
Karsten Hopp bdba8b
--- 1729,1735 ----
Karsten Hopp bdba8b
  	       continue;
Karsten Hopp bdba8b
  
Karsten Hopp bdba8b
  	   context = (char *)alloc((unsigned)strlen(cntx)+5);
Karsten Hopp bdba8b
! 	   if (context == NULL)
Karsten Hopp bdba8b
  	       continue;
Karsten Hopp bdba8b
  
Karsten Hopp bdba8b
  	   if (strcmp(cntx, "<global>")==0)
Karsten Hopp bdba8b
***************
Karsten Hopp bdba8b
*** 1731,1737 ****
Karsten Hopp bdba8b
  	   else
Karsten Hopp bdba8b
  	       sprintf(context, "<<%s>>", cntx);
Karsten Hopp bdba8b
  
Karsten Hopp bdba8b
! 	   if (search==NULL)
Karsten Hopp bdba8b
  	       fprintf(f, "%s\t%s\t%s\n", fullname, slno, context);
Karsten Hopp bdba8b
  	   else
Karsten Hopp bdba8b
  	       fprintf(f, "%s\t%s\t%s %s\n", fullname, slno, context, search);
Karsten Hopp bdba8b
--- 1737,1743 ----
Karsten Hopp bdba8b
  	   else
Karsten Hopp bdba8b
  	       sprintf(context, "<<%s>>", cntx);
Karsten Hopp bdba8b
  
Karsten Hopp bdba8b
! 	   if (search == NULL)
Karsten Hopp bdba8b
  	       fprintf(f, "%s\t%s\t%s\n", fullname, slno, context);
Karsten Hopp bdba8b
  	   else
Karsten Hopp bdba8b
  	       fprintf(f, "%s\t%s\t%s %s\n", fullname, slno, context, search);
Karsten Hopp bdba8b
*** ../vim-7.0.152/src/version.c	Tue Oct 24 22:31:51 2006
Karsten Hopp bdba8b
--- src/version.c	Mon Oct 30 22:29:45 2006
Karsten Hopp bdba8b
***************
Karsten Hopp bdba8b
*** 668,669 ****
Karsten Hopp bdba8b
--- 668,671 ----
Karsten Hopp bdba8b
  {   /* Add new patch number below this line */
Karsten Hopp bdba8b
+ /**/
Karsten Hopp bdba8b
+     153,
Karsten Hopp bdba8b
  /**/
Karsten Hopp bdba8b
Karsten Hopp bdba8b
-- 
Karsten Hopp bdba8b
You cannot have a baby in one month by getting nine women pregnant.
Karsten Hopp bdba8b
Karsten Hopp bdba8b
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp bdba8b
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp bdba8b
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp bdba8b
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///