diff src/fold.c @ 22023:67d3826948ad v8.2.1561

patch 8.2.1561: using NULL pointers in fold code Commit: https://github.com/vim/vim/commit/81fcb67fb32a12414512b72e691a1bbbff9f8511 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Sep 1 21:21:24 2020 +0200 patch 8.2.1561: using NULL pointers in fold code Problem: Using NULL pointers in fold code. Solution: Avoid using a NULL pointer. (Dominique Pell?, closes https://github.com/vim/vim/issues/6831, closes #6831)
author Bram Moolenaar <Bram@vim.org>
date Tue, 01 Sep 2020 21:30:04 +0200
parents 514d622473af
children 86696c617f70
line wrap: on
line diff
--- a/src/fold.c
+++ b/src/fold.c
@@ -3059,7 +3059,7 @@ truncate_fold(fold_T *fp, linenr_T end)
 }
 
 #define fold_end(fp) ((fp)->fd_top + (fp)->fd_len - 1)
-#define valid_fold(fp, gap) ((fp) < ((fold_T *)(gap)->ga_data + (gap)->ga_len))
+#define valid_fold(fp, gap) ((gap)->ga_len > 0 && (fp) < ((fold_T *)(gap)->ga_data + (gap)->ga_len))
 #define fold_index(fp, gap) ((size_t)(fp - ((fold_T *)(gap)->ga_data)))
 
     void