Mercurial > vim
comparison src/cindent.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 | 6cdf55afaae9 |
children | d3058719eff5 |
comparison
equal
deleted
inserted
replaced
29339:a023e3008ae3 | 29340:fba9e366ced4 |
---|---|
2792 else if (!curbuf->b_ind_js) | 2792 else if (!curbuf->b_ind_js) |
2793 amount += ind_continuation; | 2793 amount += ind_continuation; |
2794 break; | 2794 break; |
2795 } | 2795 } |
2796 | 2796 |
2797 l = ml_get_curline(); | |
2798 | |
2799 // If we're in a comment or raw string now, skip to | 2797 // If we're in a comment or raw string now, skip to |
2800 // the start of it. | 2798 // the start of it. |
2801 trypos = ind_find_start_CORS(NULL); | 2799 trypos = ind_find_start_CORS(NULL); |
2802 if (trypos != NULL) | 2800 if (trypos != NULL) |
2803 { | 2801 { |
2804 curwin->w_cursor.lnum = trypos->lnum + 1; | 2802 curwin->w_cursor.lnum = trypos->lnum + 1; |
2805 curwin->w_cursor.col = 0; | 2803 curwin->w_cursor.col = 0; |
2806 continue; | 2804 continue; |
2807 } | 2805 } |
2806 | |
2807 l = ml_get_curline(); | |
2808 | 2808 |
2809 // Skip preprocessor directives and blank lines. | 2809 // Skip preprocessor directives and blank lines. |
2810 if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, | 2810 if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, |
2811 &amount)) | 2811 &amount)) |
2812 continue; | 2812 continue; |
2903 if (curwin->w_cursor.lnum == 0 | 2903 if (curwin->w_cursor.lnum == 0 |
2904 || curwin->w_cursor.lnum | 2904 || curwin->w_cursor.lnum |
2905 < ourscope - FIND_NAMESPACE_LIM) | 2905 < ourscope - FIND_NAMESPACE_LIM) |
2906 break; | 2906 break; |
2907 | 2907 |
2908 l = ml_get_curline(); | |
2909 | |
2910 // If we're in a comment or raw string now, skip | 2908 // If we're in a comment or raw string now, skip |
2911 // to the start of it. | 2909 // to the start of it. |
2912 trypos = ind_find_start_CORS(NULL); | 2910 trypos = ind_find_start_CORS(NULL); |
2913 if (trypos != NULL) | 2911 if (trypos != NULL) |
2914 { | 2912 { |
2915 curwin->w_cursor.lnum = trypos->lnum + 1; | 2913 curwin->w_cursor.lnum = trypos->lnum + 1; |
2916 curwin->w_cursor.col = 0; | 2914 curwin->w_cursor.col = 0; |
2917 continue; | 2915 continue; |
2918 } | 2916 } |
2917 | |
2918 l = ml_get_curline(); | |
2919 | 2919 |
2920 // Skip preprocessor directives and blank lines. | 2920 // Skip preprocessor directives and blank lines. |
2921 if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, | 2921 if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, |
2922 &amount)) | 2922 &amount)) |
2923 continue; | 2923 continue; |
3194 if (trypos != NULL && (trypos->lnum < tryposBrace->lnum | 3194 if (trypos != NULL && (trypos->lnum < tryposBrace->lnum |
3195 || (trypos->lnum == tryposBrace->lnum | 3195 || (trypos->lnum == tryposBrace->lnum |
3196 && trypos->col < tryposBrace->col))) | 3196 && trypos->col < tryposBrace->col))) |
3197 trypos = NULL; | 3197 trypos = NULL; |
3198 | 3198 |
3199 l = ml_get_curline(); | |
3200 | |
3199 // If we are looking for ',', we also look for matching | 3201 // If we are looking for ',', we also look for matching |
3200 // braces. | 3202 // braces. |
3201 if (trypos == NULL && terminated == ',' | 3203 if (trypos == NULL && terminated == ',') |
3202 && find_last_paren(l, '{', '}')) | 3204 { |
3203 trypos = find_start_brace(); | 3205 if (find_last_paren(l, '{', '}')) |
3206 trypos = find_start_brace(); | |
3207 l = ml_get_curline(); | |
3208 } | |
3204 | 3209 |
3205 if (trypos != NULL) | 3210 if (trypos != NULL) |
3206 { | 3211 { |
3207 // Check if we are on a case label now. This is | 3212 // Check if we are on a case label now. This is |
3208 // handled above. | 3213 // handled above. |
3231 if (*l == NUL || l[STRLEN(l) - 1] != '\\') | 3236 if (*l == NUL || l[STRLEN(l) - 1] != '\\') |
3232 break; | 3237 break; |
3233 --curwin->w_cursor.lnum; | 3238 --curwin->w_cursor.lnum; |
3234 curwin->w_cursor.col = 0; | 3239 curwin->w_cursor.col = 0; |
3235 } | 3240 } |
3241 l = ml_get_curline(); | |
3236 } | 3242 } |
3237 | 3243 |
3238 // Get indent and pointer to text for current line, | 3244 // Get indent and pointer to text for current line, |
3239 // ignoring any jump label. XXX | 3245 // ignoring any jump label. XXX |
3240 if (curbuf->b_ind_js) | 3246 if (curbuf->b_ind_js) |