comparison src/fold.c @ 22021:514d622473af v8.2.1560

patch 8.2.1560: using NULL pointers in some code Commit: https://github.com/vim/vim/commit/9c2b06637b32742cac11bfd66b1a4e84583c6c2e Author: Bram Moolenaar <Bram@vim.org> Date: Tue Sep 1 19:56:15 2020 +0200 patch 8.2.1560: using NULL pointers in some code Problem: Using NULL pointers in some code. (James McCoy) Solution: Avoid adding to a NULL pointer. Use byte as unsigned.
author Bram Moolenaar <Bram@vim.org>
date Tue, 01 Sep 2020 20:00:03 +0200
parents 24cef4317d92
children 67d3826948ad
comparison
equal deleted inserted replaced
22020:8449d4a87818 22021:514d622473af
1312 for (;;) 1312 for (;;)
1313 { 1313 {
1314 if (!foldFind(gap, lnum, &fp)) 1314 if (!foldFind(gap, lnum, &fp))
1315 { 1315 {
1316 // If there is a following fold, continue there next time. 1316 // If there is a following fold, continue there next time.
1317 if (fp < (fold_T *)gap->ga_data + gap->ga_len) 1317 if (fp != NULL && fp < (fold_T *)gap->ga_data + gap->ga_len)
1318 next = fp->fd_top + off; 1318 next = fp->fd_top + off;
1319 break; 1319 break;
1320 } 1320 }
1321 1321
1322 // lnum is inside this fold 1322 // lnum is inside this fold
2903 2903
2904 // Move nested folds below bot to new fold. There can't be 2904 // Move nested folds below bot to new fold. There can't be
2905 // any between top and bot, they have been removed by the caller. 2905 // any between top and bot, they have been removed by the caller.
2906 gap1 = &fp->fd_nested; 2906 gap1 = &fp->fd_nested;
2907 gap2 = &fp[1].fd_nested; 2907 gap2 = &fp[1].fd_nested;
2908 (void)(foldFind(gap1, bot + 1 - fp->fd_top, &fp2)); 2908 if (foldFind(gap1, bot + 1 - fp->fd_top, &fp2))
2909 len = (int)((fold_T *)gap1->ga_data + gap1->ga_len - fp2); 2909 {
2910 if (len > 0 && ga_grow(gap2, len) == OK) 2910 len = (int)((fold_T *)gap1->ga_data + gap1->ga_len - fp2);
2911 { 2911 if (len > 0 && ga_grow(gap2, len) == OK)
2912 for (idx = 0; idx < len; ++idx) 2912 {
2913 { 2913 for (idx = 0; idx < len; ++idx)
2914 ((fold_T *)gap2->ga_data)[idx] = fp2[idx]; 2914 {
2915 ((fold_T *)gap2->ga_data)[idx].fd_top 2915 ((fold_T *)gap2->ga_data)[idx] = fp2[idx];
2916 -= fp[1].fd_top - fp->fd_top; 2916 ((fold_T *)gap2->ga_data)[idx].fd_top
2917 } 2917 -= fp[1].fd_top - fp->fd_top;
2918 gap2->ga_len = len; 2918 }
2919 gap1->ga_len -= len; 2919 gap2->ga_len = len;
2920 gap1->ga_len -= len;
2921 }
2920 } 2922 }
2921 fp->fd_len = top - fp->fd_top; 2923 fp->fd_len = top - fp->fd_top;
2922 fold_changed = TRUE; 2924 fold_changed = TRUE;
2923 } 2925 }
2924 2926