aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2020-09-03 22:28:27 -0400
committerJames McCoy <jamessan@jamessan.com>2020-09-04 08:25:33 -0400
commit11901922167924e95b2af7f2eab59943f6aa02a5 (patch)
tree76dffb305b4de48a5b8278b6e08d919169585c39
parentae8f10873291bd35421d5d910154d9750779747e (diff)
downloadrneovim-11901922167924e95b2af7f2eab59943f6aa02a5.tar.gz
rneovim-11901922167924e95b2af7f2eab59943f6aa02a5.tar.bz2
rneovim-11901922167924e95b2af7f2eab59943f6aa02a5.zip
vim-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. https://github.com/vim/vim/commit/9c2b06637b32742cac11bfd66b1a4e84583c6c2e The changes to eval.c (skip_expr_concatenate) and vim9compile.c aren't included since they're specific to vim9script support.
-rw-r--r--src/nvim/fold.c25
-rw-r--r--src/nvim/spell.c3
2 files changed, 16 insertions, 12 deletions
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index 3d631a158e..a197be28d7 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -1232,7 +1232,7 @@ setManualFoldWin(
for (;; ) {
if (!foldFind(gap, lnum, &fp)) {
/* If there is a following fold, continue there next time. */
- if (fp < (fold_T *)gap->ga_data + gap->ga_len)
+ if (fp != NULL && fp < (fold_T *)gap->ga_data + gap->ga_len)
next = fp->fd_top + off;
break;
}
@@ -2615,17 +2615,18 @@ static void foldSplit(buf_T *buf, garray_T *const gap,
* any between top and bot, they have been removed by the caller. */
garray_T *const gap1 = &fp->fd_nested;
garray_T *const gap2 = &fp[1].fd_nested;
- (void)(foldFind(gap1, bot + 1 - fp->fd_top, &fp2));
- const int len = (int)((fold_T *)gap1->ga_data + gap1->ga_len - fp2);
- if (len > 0) {
- ga_grow(gap2, len);
- for (int idx = 0; idx < len; idx++) {
- ((fold_T *)gap2->ga_data)[idx] = fp2[idx];
- ((fold_T *)gap2->ga_data)[idx].fd_top
- -= fp[1].fd_top - fp->fd_top;
- }
- gap2->ga_len = len;
- gap1->ga_len -= len;
+ if (foldFind(gap1, bot + 1 - fp->fd_top, &fp2)) {
+ const int len = (int)((fold_T *)gap1->ga_data + gap1->ga_len - fp2);
+ if (len > 0) {
+ ga_grow(gap2, len);
+ for (int idx = 0; idx < len; idx++) {
+ ((fold_T *)gap2->ga_data)[idx] = fp2[idx];
+ ((fold_T *)gap2->ga_data)[idx].fd_top
+ -= fp[1].fd_top - fp->fd_top;
+ }
+ gap2->ga_len = len;
+ gap1->ga_len -= len;
+ }
}
fp->fd_len = top - fp->fd_top;
fold_changed = true;
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index ad235f1f14..05bb501fa2 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -5663,6 +5663,9 @@ check_suggestions (
int len;
hlf_T attr;
+ if (gap->ga_len == 0) {
+ return;
+ }
stp = &SUG(*gap, 0);
for (int i = gap->ga_len - 1; i >= 0; --i) {
// Need to append what follows to check for "the the".