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

@@ -49,10 +49,11 @@ typedef struct memline {
int ml_stack_top; // current top of ml_stack
int ml_stack_size; // total number of entries in ml_stack
#define ML_EMPTY 1 // empty buffer
#define ML_LINE_DIRTY 2 // cached line was changed and allocated
#define ML_LOCKED_DIRTY 4 // ml_locked was changed
#define ML_LOCKED_POS 8 // ml_locked needs positive block number
#define ML_EMPTY 0x01 // empty buffer
#define ML_LINE_DIRTY 0x02 // cached line was changed and allocated
#define ML_LOCKED_DIRTY 0x04 // ml_locked was changed
#define ML_LOCKED_POS 0x08 // ml_locked needs positive block number
#define ML_ALLOCATED 0x10 // ml_line_ptr is an allocated copy
int ml_flags;
linenr_T ml_line_lnum; // line number of cached line, 0 if not valid