diff options
author | Michael Ennen <mike.ennen@gmail.com> | 2017-03-23 01:58:05 -0700 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2017-06-08 10:27:39 -0400 |
commit | edced212db84a3b0348fe40e41b59492a9504132 (patch) | |
tree | 5f62a2c6eae2e43c0d787a7a89480ef9635e75aa /src | |
parent | 16cce1ac17456e3758f95af6ce7289bade3bb285 (diff) | |
download | rneovim-edced212db84a3b0348fe40e41b59492a9504132.tar.gz rneovim-edced212db84a3b0348fe40e41b59492a9504132.tar.bz2 rneovim-edced212db84a3b0348fe40e41b59492a9504132.zip |
vim-patch:7.4.2360
Problem: Invalid memory access when formatting. (Dominique Pelle)
Solution: Make sure cursor line and column are associated.
https://github.com/vim/vim/commit/80c3fd7c559c7d329d57afe10db9bfb0adf10e46
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/indent_c.c | 39 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
2 files changed, 23 insertions, 18 deletions
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 4806f46705..fd194a4080 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -822,21 +822,22 @@ cin_isterminated ( return found_start; } -/* - * Recognize the basic picture of a function declaration -- it needs to - * have an open paren somewhere and a close paren at the end of the line and - * no semicolons anywhere. - * When a line ends in a comma we continue looking in the next line. - * "sp" points to a string with the line. When looking at other lines it must - * be restored to the line. When it's NULL fetch lines here. - * "lnum" is where we start looking. - * "min_lnum" is the line before which we will not be looking. - */ +/// Recognizes the basic picture of a function declaration -- it needs to +/// have an open paren somewhere and a close paren at the end of the line and +/// no semicolons anywhere. +/// When a line ends in a comma we continue looking in the next line. +/// +/// @param[in] sp Points to a string with the line. When looking at other +/// lines it must be restored to the line. When it's NULL fetch +/// lines here. +/// @param[in] first_lnum Where to start looking. +/// @param[in] min_lnum The line before which we will not be looking. static int cin_isfuncdecl(char_u **sp, linenr_T first_lnum, linenr_T min_lnum) { char_u *s; linenr_T lnum = first_lnum; - int retval = FALSE; + linenr_T save_lnum = curwin->w_cursor.lnum; + int retval = false; pos_T *trypos; int just_started = TRUE; @@ -845,18 +846,22 @@ static int cin_isfuncdecl(char_u **sp, linenr_T first_lnum, linenr_T min_lnum) else s = *sp; + curwin->w_cursor.lnum = lnum; if (find_last_paren(s, '(', ')') && (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) { lnum = trypos->lnum; - if (lnum < min_lnum) - return FALSE; - + if (lnum < min_lnum) { + curwin->w_cursor.lnum = save_lnum; + return false; + } s = ml_get(lnum); } - /* Ignore line starting with #. */ - if (cin_ispreproc(s)) - return FALSE; + curwin->w_cursor.lnum = save_lnum; + // Ignore line starting with #. + if (cin_ispreproc(s)) { + return false; + } while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"') { // ignore comments diff --git a/src/nvim/version.c b/src/nvim/version.c index 804968af3d..70fbf3a9e6 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -84,7 +84,7 @@ static const int included_patches[] = { // 2363 NA 2362, // 2361 NA - // 2360, + 2360, 2359, // 2358 NA 2357, |