aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/indent_c.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-03-04 14:19:53 +0800
committerGitHub <noreply@github.com>2023-03-04 14:19:53 +0800
commitde14f2c928f913d4fb617d693024eec5cf2223ec (patch)
tree34e2b7c7324382eb0058e1dffa2d1baa1ab2ae0d /src/nvim/indent_c.c
parent446c353a507834a3cbe9007b06e7e0c2c46b5ac7 (diff)
parentb7d59649acf43c76cc72b25c04bcae926a40b4fe (diff)
downloadrneovim-de14f2c928f913d4fb617d693024eec5cf2223ec.tar.gz
rneovim-de14f2c928f913d4fb617d693024eec5cf2223ec.tar.bz2
rneovim-de14f2c928f913d4fb617d693024eec5cf2223ec.zip
Merge pull request #22506 from zeertzjq/vim-9.0.0013
vim-patch:9.0.{partial:0013,0016}: fix memory access errors
Diffstat (limited to 'src/nvim/indent_c.c')
-rw-r--r--src/nvim/indent_c.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 1c771073b2..3e7f640326 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -2529,8 +2529,6 @@ int get_c_indent(void)
break;
}
- l = get_cursor_line_ptr();
-
// If we're in a comment or raw string now, skip to
// the start of it.
trypos = ind_find_start_CORS(NULL);
@@ -2540,9 +2538,9 @@ int get_c_indent(void)
continue;
}
- //
+ l = get_cursor_line_ptr();
+
// Skip preprocessor directives and blank lines.
- //
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)) {
continue;
}
@@ -2640,8 +2638,6 @@ int get_c_indent(void)
break;
}
- l = get_cursor_line_ptr();
-
// If we're in a comment or raw string now, skip
// to the start of it.
trypos = ind_find_start_CORS(NULL);
@@ -2651,6 +2647,8 @@ int get_c_indent(void)
continue;
}
+ l = get_cursor_line_ptr();
+
// Skip preprocessor directives and blank lines.
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)) {
continue;
@@ -2916,11 +2914,15 @@ int get_c_indent(void)
trypos = NULL;
}
+ l = get_cursor_line_ptr();
+
// If we are looking for ',', we also look for matching
// braces.
- if (trypos == NULL && terminated == ','
- && find_last_paren(l, '{', '}')) {
- trypos = find_start_brace();
+ if (trypos == NULL && terminated == ',') {
+ if (find_last_paren(l, '{', '}')) {
+ trypos = find_start_brace();
+ }
+ l = get_cursor_line_ptr();
}
if (trypos != NULL) {
@@ -2951,6 +2953,7 @@ int get_c_indent(void)
curwin->w_cursor.lnum--;
curwin->w_cursor.col = 0;
}
+ l = get_cursor_line_ptr();
}
// Get indent and pointer to text for current line,