To: vim-dev@vim.org Subject: Patch 6.3.076 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.3.076 Problem: Crash when using cscope and there is a parse error (e.g., line too long). (Alexey I. Froloff) Solution: Pass the actual number of matches to cs_manage_matches() and correctly handle the error situation. Files: src/if_cscope.c *** ../vim-6.3.075/src/if_cscope.c Wed Jun 9 14:56:27 2004 --- src/if_cscope.c Tue Jun 7 11:06:19 2005 *************** *** 1,7 **** /* vi:set ts=8 sts=4 sw=4: * * CSCOPE support for Vim added by Andy Kahn ! * Ported to Win32 by Sergey Khorev * * The basic idea/structure of cscope for Vim was borrowed from Nvi. There * might be a few lines of code that look similar to what Nvi has. --- 1,7 ---- /* vi:set ts=8 sts=4 sw=4: * * CSCOPE support for Vim added by Andy Kahn ! * Ported to Win32 by Sergey Khorev * * The basic idea/structure of cscope for Vim was borrowed from Nvi. There * might be a few lines of code that look similar to what Nvi has. *************** *** 1130,1136 **** if (matches == NULL) return FALSE; ! (void)cs_manage_matches(matches, contexts, totmatches, Store); return do_tag((char_u *)pat, DT_CSCOPE, 0, forceit, verbose); } --- 1130,1136 ---- if (matches == NULL) return FALSE; ! (void)cs_manage_matches(matches, contexts, matched, Store); return do_tag((char_u *)pat, DT_CSCOPE, 0, forceit, verbose); } *************** *** 1726,1731 **** --- 1726,1732 ---- * * get parsed cscope output and calls cs_make_vim_style_matches to convert * into ctags format + * When there are no matches sets "*matches_p" to NULL. */ static void cs_fill_results(tagstr, totmatches, nummatches_a, matches_p, cntxts_p, matched) *************** *** 1790,1795 **** --- 1791,1804 ---- } /* for all cscope connections */ parse_out: + if (totsofar == 0) + { + /* No matches, free the arrays and return NULL in "*matches_p". */ + vim_free(matches); + matches = NULL; + vim_free(cntxts); + cntxts = NULL; + } *matched = totsofar; *matches_p = matches; *cntxts_p = cntxts; *************** *** 2125,2131 **** { char **dblist = NULL, **pplist = NULL, **fllist = NULL; int i; ! char buf[8]; /* for sprintf " (#%d)" */ /* malloc our db and ppath list */ dblist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *)); --- 2134,2140 ---- { char **dblist = NULL, **pplist = NULL, **fllist = NULL; int i; ! char buf[20]; /* for sprintf " (#%d)" */ /* malloc our db and ppath list */ dblist = (char **)alloc(CSCOPE_MAX_CONNECTIONS * sizeof(char *)); *** ../vim-6.3.075/src/version.c Tue May 31 21:30:24 2005 --- src/version.c Tue Jun 7 11:06:46 2005 *************** *** 643,644 **** --- 643,646 ---- { /* Add new patch number below this line */ + /**/ + 76, /**/ -- Despite the cost of living, have you noticed how it remains so popular? /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///