Mercurial > vim
comparison src/edit.c @ 29340:fba9e366ced4 v9.0.0013
patch 9.0.0013: reproducing memory access errors can be difficult
Commit: https://github.com/vim/vim/commit/fa4873ccfc10e0f278dc46f39d00136fab059b19
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 30 22:13:59 2022 +0100
patch 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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 30 Jun 2022 23:15:03 +0200 |
parents | 3e5166df3004 |
children | 057c26b5c33a |
comparison
equal
deleted
inserted
replaced
29339:a023e3008ae3 | 29340:fba9e366ced4 |
---|---|
5011 if (col > 0) | 5011 if (col > 0) |
5012 mch_memmove(newp, ptr - col, col); | 5012 mch_memmove(newp, ptr - col, col); |
5013 mch_memmove(newp + col, ptr + i, | 5013 mch_memmove(newp + col, ptr + i, |
5014 curbuf->b_ml.ml_line_len - col - i); | 5014 curbuf->b_ml.ml_line_len - col - i); |
5015 | 5015 |
5016 if (curbuf->b_ml.ml_flags & ML_LINE_DIRTY) | 5016 if (curbuf->b_ml.ml_flags & (ML_LINE_DIRTY | ML_ALLOCATED)) |
5017 vim_free(curbuf->b_ml.ml_line_ptr); | 5017 vim_free(curbuf->b_ml.ml_line_ptr); |
5018 curbuf->b_ml.ml_line_ptr = newp; | 5018 curbuf->b_ml.ml_line_ptr = newp; |
5019 curbuf->b_ml.ml_line_len -= i; | 5019 curbuf->b_ml.ml_line_len -= i; |
5020 curbuf->b_ml.ml_flags = | 5020 curbuf->b_ml.ml_flags = |
5021 (curbuf->b_ml.ml_flags | ML_LINE_DIRTY) & ~ML_EMPTY; | 5021 (curbuf->b_ml.ml_flags | ML_LINE_DIRTY) & ~ML_EMPTY; |
5230 vim_beep(BO_COPY); | 5230 vim_beep(BO_COPY); |
5231 return NUL; | 5231 return NUL; |
5232 } | 5232 } |
5233 | 5233 |
5234 // try to advance to the cursor column | 5234 // try to advance to the cursor column |
5235 validate_virtcol(); | |
5235 temp = 0; | 5236 temp = 0; |
5236 line = ptr = ml_get(lnum); | 5237 line = ptr = ml_get(lnum); |
5237 prev_ptr = ptr; | 5238 prev_ptr = ptr; |
5238 validate_virtcol(); | |
5239 while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL) | 5239 while ((colnr_T)temp < curwin->w_virtcol && *ptr != NUL) |
5240 { | 5240 { |
5241 prev_ptr = ptr; | 5241 prev_ptr = ptr; |
5242 temp += lbr_chartabsize_adv(line, &ptr, (colnr_T)temp); | 5242 temp += lbr_chartabsize_adv(line, &ptr, (colnr_T)temp); |
5243 } | 5243 } |