vim-patch:partial:9.0.0013: reproducing memory access errors can be difficult

Problem:    Reproducing memory access errors can be difficult.
Solution:   When testing, copy each line to allocated memory, so that valgrind
            can detect accessing memory before and/or after it.  Fix uncovered
            problems.

fa4873ccfc

Since test_override() is N/A, enable ml_get_alloc_lines when ASAN is
enabled instead, so it also applies to functional tests.

Use xstrdup() to copy the line as ml_line_len looks hard to port.

Squash the test changes from patch 9.0.0016.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-03-04 10:25:18 +08:00
parent 446c353a50
commit 0a897f89c5
7 changed files with 67 additions and 32 deletions

View File

@@ -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,