0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.1552: warnings from asan with clang-11

Problem:    Warnings from asan with clang-11. (James McCoy)
Solution:   Avoid using a NULL pointer. (issue #6811)
This commit is contained in:
Bram Moolenaar
2020-08-31 19:58:13 +02:00
parent 8b565c2c15
commit 64f37d3090
2 changed files with 25 additions and 11 deletions

View File

@@ -820,13 +820,16 @@ foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
return; return;
#endif #endif
// Mark all folds from top to bot as maybe-small. if (wp->w_folds.ga_len > 0)
(void)foldFind(&wp->w_folds, top, &fp);
while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
&& fp->fd_top < bot)
{ {
fp->fd_small = MAYBE; // Mark all folds from top to bot as maybe-small.
++fp; (void)foldFind(&wp->w_folds, top, &fp);
while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
&& fp->fd_top < bot)
{
fp->fd_small = MAYBE;
++fp;
}
} }
if (foldmethodIsIndent(wp) if (foldmethodIsIndent(wp)
@@ -1127,6 +1130,12 @@ foldFind(garray_T *gap, linenr_T lnum, fold_T **fpp)
fold_T *fp; fold_T *fp;
int i; int i;
if (gap->ga_len == 0)
{
*fpp = NULL;
return FALSE;
}
/* /*
* Perform a binary search. * Perform a binary search.
* "low" is lowest index of possible match. * "low" is lowest index of possible match.
@@ -2500,14 +2509,14 @@ foldUpdateIEMSRecurse(
// Find an existing fold to re-use. Preferably one that // Find an existing fold to re-use. Preferably one that
// includes startlnum, otherwise one that ends just before // includes startlnum, otherwise one that ends just before
// startlnum or starts after it. // startlnum or starts after it.
if (foldFind(gap, startlnum, &fp) if (gap->ga_len > 0 && (foldFind(gap, startlnum, &fp)
|| (fp < ((fold_T *)gap->ga_data) + gap->ga_len || (fp < ((fold_T *)gap->ga_data) + gap->ga_len
&& fp->fd_top <= firstlnum) && fp->fd_top <= firstlnum)
|| foldFind(gap, firstlnum - concat, &fp) || foldFind(gap, firstlnum - concat, &fp)
|| (fp < ((fold_T *)gap->ga_data) + gap->ga_len || (fp < ((fold_T *)gap->ga_data) + gap->ga_len
&& ((lvl < level && fp->fd_top < flp->lnum) && ((lvl < level && fp->fd_top < flp->lnum)
|| (lvl >= level || (lvl >= level
&& fp->fd_top <= flp->lnum_save)))) && fp->fd_top <= flp->lnum_save)))))
{ {
if (fp->fd_top + fp->fd_len + concat > firstlnum) if (fp->fd_top + fp->fd_len + concat > firstlnum)
{ {
@@ -2622,7 +2631,10 @@ foldUpdateIEMSRecurse(
{ {
// Insert new fold. Careful: ga_data may be NULL and it // Insert new fold. Careful: ga_data may be NULL and it
// may change! // may change!
i = (int)(fp - (fold_T *)gap->ga_data); if (gap->ga_len == 0)
i = 0;
else
i = (int)(fp - (fold_T *)gap->ga_data);
if (foldInsert(gap, i) != OK) if (foldInsert(gap, i) != OK)
return bot; return bot;
fp = (fold_T *)gap->ga_data + i; fp = (fold_T *)gap->ga_data + i;
@@ -2841,7 +2853,7 @@ foldInsert(garray_T *gap, int i)
if (ga_grow(gap, 1) != OK) if (ga_grow(gap, 1) != OK)
return FAIL; return FAIL;
fp = (fold_T *)gap->ga_data + i; fp = (fold_T *)gap->ga_data + i;
if (i < gap->ga_len) if (gap->ga_len > 0 && i < gap->ga_len)
mch_memmove(fp + 1, fp, sizeof(fold_T) * (gap->ga_len - i)); mch_memmove(fp + 1, fp, sizeof(fold_T) * (gap->ga_len - i));
++gap->ga_len; ++gap->ga_len;
ga_init2(&fp->fd_nested, (int)sizeof(fold_T), 10); ga_init2(&fp->fd_nested, (int)sizeof(fold_T), 10);
@@ -2928,7 +2940,7 @@ foldRemove(garray_T *gap, linenr_T top, linenr_T bot)
if (bot < top) if (bot < top)
return; // nothing to do return; // nothing to do
for (;;) while (gap->ga_len > 0)
{ {
// Find fold that includes top or a following one. // Find fold that includes top or a following one.
if (foldFind(gap, top, &fp) && fp->fd_top < top) if (foldFind(gap, top, &fp) && fp->fd_top < top)

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1552,
/**/ /**/
1551, 1551,
/**/ /**/