Patch 9.0.1251
Problem:    Checking returned value of ga_grow() is inconsistent.
Solution:   Check for FAIL instaed of "not OK". (Yegappan Lakshmanan,
            closes #11897)
Files:      src/digraph.c, src/evalfunc.c, src/fold.c, src/getchar.c,
            src/map.c, src/os_win32.c, src/scriptfile.c, src/spellfile.c,
            src/syntax.c, src/tag.c, src/usercmd.c


*** ../vim-9.0.1250/src/digraph.c       2023-01-22 21:14:32.613863616 +0000
--- src/digraph.c       2023-01-27 21:01:01.583159981 +0000
***************
*** 1682,1688 ****
      }
  
      // Add a new digraph to the table.
!     if (ga_grow(&user_digraphs, 1) != OK)
        return;
  
      dp = (digr_T *)user_digraphs.ga_data + user_digraphs.ga_len;
--- 1682,1688 ----
      }
  
      // Add a new digraph to the table.
!     if (ga_grow(&user_digraphs, 1) == FAIL)
        return;
  
      dp = (digr_T *)user_digraphs.ga_data + user_digraphs.ga_len;
*** ../vim-9.0.1250/src/evalfunc.c      2023-01-22 20:14:22.898453926 +0000
--- src/evalfunc.c      2023-01-27 21:01:01.587159979 +0000
***************
*** 3966,3972 ****
        len = (int)STRLEN(value);       // Append the entire string
      else
        len = value_len;                // Append only "value_len" characters
!     if (ga_grow(&redir_execute_ga, len) != OK)
        return;
  
      mch_memmove((char *)redir_execute_ga.ga_data
--- 3966,3972 ----
        len = (int)STRLEN(value);       // Append the entire string
      else
        len = value_len;                // Append only "value_len" characters
!     if (ga_grow(&redir_execute_ga, len) == FAIL)
        return;
  
      mch_memmove((char *)redir_execute_ga.ga_data
*** ../vim-9.0.1250/src/fold.c  2023-01-09 19:04:19.304528371 +0000
--- src/fold.c  2023-01-27 21:01:01.587159979 +0000
***************
*** 645,651 ****
            i = (int)(fp - (fold_T *)gap->ga_data);
      }
  
!     if (ga_grow(gap, 1) != OK)
        return;
  
      fp = (fold_T *)gap->ga_data + i;
--- 645,651 ----
            i = (int)(fp - (fold_T *)gap->ga_data);
      }
  
!     if (ga_grow(gap, 1) == FAIL)
        return;
  
      fp = (fold_T *)gap->ga_data + i;
***************
*** 2884,2890 ****
  {
      fold_T    *fp;
  
!     if (ga_grow(gap, 1) != OK)
        return FAIL;
      fp = (fold_T *)gap->ga_data + i;
      if (gap->ga_len > 0 && i < gap->ga_len)
--- 2884,2890 ----
  {
      fold_T    *fp;
  
!     if (ga_grow(gap, 1) == FAIL)
        return FAIL;
      fp = (fold_T *)gap->ga_data + i;
      if (gap->ga_len > 0 && i < gap->ga_len)
*** ../vim-9.0.1250/src/getchar.c       2023-01-25 17:34:38.013795178 +0000
--- src/getchar.c       2023-01-27 21:01:01.587159979 +0000
***************
*** 3890,3896 ****
      got_int = FALSE;
      while (c1 != NUL && !aborted)
      {
!       if (ga_grow(&line_ga, 32) != OK)
        {
            aborted = TRUE;
            break;
--- 3890,3896 ----
      got_int = FALSE;
      while (c1 != NUL && !aborted)
      {
!       if (ga_grow(&line_ga, 32) == FAIL)
        {
            aborted = TRUE;
            break;
*** ../vim-9.0.1250/src/map.c   2023-01-14 12:32:24.215984102 +0000
--- src/map.c   2023-01-27 21:01:01.587159979 +0000
***************
*** 2983,2989 ****
            b = i;
      }
  
!     if (ga_grow(&langmap_mapga, 1) != OK)
        return;  // out of memory
  
      // insert new entry at position "a"
--- 2983,2989 ----
            b = i;
      }
  
!     if (ga_grow(&langmap_mapga, 1) == FAIL)
        return;  // out of memory
  
      // insert new entry at position "a"
*** ../vim-9.0.1250/src/os_win32.c      2023-01-23 12:33:15.822715784 +0000
--- src/os_win32.c      2023-01-27 21:01:01.587159979 +0000
***************
*** 5725,5731 ****
                    size_t      lkey = wcslen(wkey);
                    size_t      lval = wcslen(wval);
  
!                   if (ga_grow(gap, (int)(lkey + lval + 2)) != OK)
                        continue;
                    for (n = 0; n < lkey; n++)
                        *((WCHAR*)gap->ga_data + gap->ga_len++) = wkey[n];
--- 5725,5731 ----
                    size_t      lkey = wcslen(wkey);
                    size_t      lval = wcslen(wval);
  
!                   if (ga_grow(gap, (int)(lkey + lval + 2)) == FAIL)
                        continue;
                    for (n = 0; n < lkey; n++)
                        *((WCHAR*)gap->ga_data + gap->ga_len++) = wkey[n];
*** ../vim-9.0.1250/src/scriptfile.c    2023-01-24 12:33:58.950777425 +0000
--- src/scriptfile.c    2023-01-27 21:01:01.587159979 +0000
***************
*** 56,62 ****
  
      // If memory allocation fails then we'll pop more than we push, eventually
      // at the top level it will be OK again.
!     if (ga_grow(&exestack, 1) != OK)
        return NULL;
  
      entry = ((estack_T *)exestack.ga_data) + exestack.ga_len;
--- 56,62 ----
  
      // If memory allocation fails then we'll pop more than we push, eventually
      // at the top level it will be OK again.
!     if (ga_grow(&exestack, 1) == FAIL)
        return NULL;
  
      entry = ((estack_T *)exestack.ga_data) + exestack.ga_len;
*** ../vim-9.0.1250/src/spellfile.c     2023-01-23 20:46:16.166493150 +0000
--- src/spellfile.c     2023-01-27 21:01:01.587159979 +0000
***************
*** 3428,3434 ****
      fromto_T  *ftp;
      char_u    word[MAXWLEN];
  
!     if (ga_grow(gap, 1) != OK)
        return;
  
      ftp = ((fromto_T *)gap->ga_data) + gap->ga_len;
--- 3428,3434 ----
      fromto_T  *ftp;
      char_u    word[MAXWLEN];
  
!     if (ga_grow(gap, 1) == FAIL)
        return;
  
      ftp = ((fromto_T *)gap->ga_data) + gap->ga_len;
*** ../vim-9.0.1250/src/syntax.c        2023-01-23 20:46:16.170493148 +0000
--- src/syntax.c        2023-01-27 21:01:01.591159977 +0000
***************
*** 1438,1444 ****
      validate_current_state();
      keepend_level = -1;
      if (from->sst_stacksize
!           && ga_grow(&current_state, from->sst_stacksize) != FAIL)
      {
        if (from->sst_stacksize > SST_FIX_STATES)
            bp = SYN_STATE_P(&(from->sst_union.sst_ga));
--- 1438,1444 ----
      validate_current_state();
      keepend_level = -1;
      if (from->sst_stacksize
!           && ga_grow(&current_state, from->sst_stacksize) == OK)
      {
        if (from->sst_stacksize > SST_FIX_STATES)
            bp = SYN_STATE_P(&(from->sst_union.sst_ga));
***************
*** 4946,4952 ****
        set_nextcmd(eap, rest);
        if (!ends_excmd2(eap->cmd, rest) || eap->skip)
            rest = NULL;
!       else if (ga_grow(&curwin->w_s->b_syn_patterns, 1) != FAIL
                && (syn_id = syn_check_group(arg,
                                           (int)(group_name_end - arg))) != 0)
        {
--- 4946,4952 ----
        set_nextcmd(eap, rest);
        if (!ends_excmd2(eap->cmd, rest) || eap->skip)
            rest = NULL;
!       else if (ga_grow(&curwin->w_s->b_syn_patterns, 1) == OK
                && (syn_id = syn_check_group(arg,
                                           (int)(group_name_end - arg))) != 0)
        {
***************
*** 5186,5192 ****
        set_nextcmd(eap, rest);
        if (!ends_excmd(*rest) || eap->skip)
            rest = NULL;
!       else if (ga_grow(&(curwin->w_s->b_syn_patterns), pat_count) != FAIL
                && (syn_id = syn_check_group(arg,
                                           (int)(group_name_end - arg))) != 0)
        {
--- 5186,5192 ----
        set_nextcmd(eap, rest);
        if (!ends_excmd(*rest) || eap->skip)
            rest = NULL;
!       else if (ga_grow(&(curwin->w_s->b_syn_patterns), pat_count) == OK
                && (syn_id = syn_check_group(arg,
                                           (int)(group_name_end - arg))) != 0)
        {
*** ../vim-9.0.1250/src/tag.c   2023-01-25 21:05:35.127042805 +0000
--- src/tag.c   2023-01-27 21:01:01.591159977 +0000
***************
*** 2739,2745 ****
        if (HASHITEM_EMPTY(hi))
        {
            if (hash_add_item(&st->ht_match[mtt], hi, mfp, *hash) == FAIL
!                   || ga_grow(&st->ga_match[mtt], 1) != OK)
            {
                // Out of memory! Just forget about the rest.
                st->stop_searching = TRUE;
--- 2739,2745 ----
        if (HASHITEM_EMPTY(hi))
        {
            if (hash_add_item(&st->ht_match[mtt], hi, mfp, *hash) == FAIL
!                   || ga_grow(&st->ga_match[mtt], 1) == FAIL)
            {
                // Out of memory! Just forget about the rest.
                st->stop_searching = TRUE;
*** ../vim-9.0.1250/src/usercmd.c       2023-01-21 21:56:02.186002026 +0000
--- src/usercmd.c       2023-01-27 21:01:01.591159977 +0000
***************
*** 1058,1064 ****
      // Extend the array unless we're replacing an existing command
      if (cmp != 0)
      {
!       if (ga_grow(gap, 1) != OK)
            goto fail;
        if ((p = vim_strnsave(name, name_len)) == NULL)
            goto fail;
--- 1058,1064 ----
      // Extend the array unless we're replacing an existing command
      if (cmp != 0)
      {
!       if (ga_grow(gap, 1) == FAIL)
            goto fail;
        if ((p = vim_strnsave(name, name_len)) == NULL)
            goto fail;
*** ../vim-9.0.1250/src/version.c       2023-01-27 20:13:58.436454834 +0000
--- src/version.c       2023-01-27 21:02:37.935115985 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1251,
  /**/

-- 
"I simultaneously try to keep my head in the clouds and my feet on the
ground.  Sometimes it's a stretch, though."              -- Larry Wall

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230127210352.B5AF21C0559%40moolenaar.net.

Raspunde prin e-mail lui