Skip to content

Commit fadc02a

Browse files
yegappanbrammool
authored andcommitted
patch 9.0.1251: checking returned value of ga_grow() is inconsistent
Problem: Checking returned value of ga_grow() is inconsistent. Solution: Check for FAIL instaed of "not OK". (Yegappan Lakshmanan, closes vim#11897)
1 parent 8dbab1d commit fadc02a

12 files changed

+16
-14
lines changed

src/digraph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ registerdigraph(int char1, int char2, int n)
16821682
}
16831683

16841684
// Add a new digraph to the table.
1685-
if (ga_grow(&user_digraphs, 1) != OK)
1685+
if (ga_grow(&user_digraphs, 1) == FAIL)
16861686
return;
16871687

16881688
dp = (digr_T *)user_digraphs.ga_data + user_digraphs.ga_len;

src/evalfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3966,7 +3966,7 @@ execute_redir_str(char_u *value, int value_len)
39663966
len = (int)STRLEN(value); // Append the entire string
39673967
else
39683968
len = value_len; // Append only "value_len" characters
3969-
if (ga_grow(&redir_execute_ga, len) != OK)
3969+
if (ga_grow(&redir_execute_ga, len) == FAIL)
39703970
return;
39713971

39723972
mch_memmove((char *)redir_execute_ga.ga_data

src/fold.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ foldCreate(linenr_T start, linenr_T end)
645645
i = (int)(fp - (fold_T *)gap->ga_data);
646646
}
647647

648-
if (ga_grow(gap, 1) != OK)
648+
if (ga_grow(gap, 1) == FAIL)
649649
return;
650650

651651
fp = (fold_T *)gap->ga_data + i;
@@ -2884,7 +2884,7 @@ foldInsert(garray_T *gap, int i)
28842884
{
28852885
fold_T *fp;
28862886

2887-
if (ga_grow(gap, 1) != OK)
2887+
if (ga_grow(gap, 1) == FAIL)
28882888
return FAIL;
28892889
fp = (fold_T *)gap->ga_data + i;
28902890
if (gap->ga_len > 0 && i < gap->ga_len)

src/getchar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3890,7 +3890,7 @@ getcmdkeycmd(
38903890
got_int = FALSE;
38913891
while (c1 != NUL && !aborted)
38923892
{
3893-
if (ga_grow(&line_ga, 32) != OK)
3893+
if (ga_grow(&line_ga, 32) == FAIL)
38943894
{
38953895
aborted = TRUE;
38963896
break;

src/map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2983,7 +2983,7 @@ langmap_set_entry(int from, int to)
29832983
b = i;
29842984
}
29852985

2986-
if (ga_grow(&langmap_mapga, 1) != OK)
2986+
if (ga_grow(&langmap_mapga, 1) == FAIL)
29872987
return; // out of memory
29882988

29892989
// insert new entry at position "a"

src/os_win32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5725,7 +5725,7 @@ win32_build_env(dict_T *env, garray_T *gap, int is_terminal)
57255725
size_t lkey = wcslen(wkey);
57265726
size_t lval = wcslen(wval);
57275727

5728-
if (ga_grow(gap, (int)(lkey + lval + 2)) != OK)
5728+
if (ga_grow(gap, (int)(lkey + lval + 2)) == FAIL)
57295729
continue;
57305730
for (n = 0; n < lkey; n++)
57315731
*((WCHAR*)gap->ga_data + gap->ga_len++) = wkey[n];

src/scriptfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ estack_push(etype_T type, char_u *name, long lnum)
5656

5757
// If memory allocation fails then we'll pop more than we push, eventually
5858
// at the top level it will be OK again.
59-
if (ga_grow(&exestack, 1) != OK)
59+
if (ga_grow(&exestack, 1) == FAIL)
6060
return NULL;
6161

6262
entry = ((estack_T *)exestack.ga_data) + exestack.ga_len;

src/spellfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3428,7 +3428,7 @@ add_fromto(
34283428
fromto_T *ftp;
34293429
char_u word[MAXWLEN];
34303430

3431-
if (ga_grow(gap, 1) != OK)
3431+
if (ga_grow(gap, 1) == FAIL)
34323432
return;
34333433

34343434
ftp = ((fromto_T *)gap->ga_data) + gap->ga_len;

src/syntax.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ load_current_state(synstate_T *from)
14381438
validate_current_state();
14391439
keepend_level = -1;
14401440
if (from->sst_stacksize
1441-
&& ga_grow(&current_state, from->sst_stacksize) != FAIL)
1441+
&& ga_grow(&current_state, from->sst_stacksize) == OK)
14421442
{
14431443
if (from->sst_stacksize > SST_FIX_STATES)
14441444
bp = SYN_STATE_P(&(from->sst_union.sst_ga));
@@ -4946,7 +4946,7 @@ syn_cmd_match(
49464946
set_nextcmd(eap, rest);
49474947
if (!ends_excmd2(eap->cmd, rest) || eap->skip)
49484948
rest = NULL;
4949-
else if (ga_grow(&curwin->w_s->b_syn_patterns, 1) != FAIL
4949+
else if (ga_grow(&curwin->w_s->b_syn_patterns, 1) == OK
49504950
&& (syn_id = syn_check_group(arg,
49514951
(int)(group_name_end - arg))) != 0)
49524952
{
@@ -5186,7 +5186,7 @@ syn_cmd_region(
51865186
set_nextcmd(eap, rest);
51875187
if (!ends_excmd(*rest) || eap->skip)
51885188
rest = NULL;
5189-
else if (ga_grow(&(curwin->w_s->b_syn_patterns), pat_count) != FAIL
5189+
else if (ga_grow(&(curwin->w_s->b_syn_patterns), pat_count) == OK
51905190
&& (syn_id = syn_check_group(arg,
51915191
(int)(group_name_end - arg))) != 0)
51925192
{

src/tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2739,7 +2739,7 @@ findtags_add_match(
27392739
if (HASHITEM_EMPTY(hi))
27402740
{
27412741
if (hash_add_item(&st->ht_match[mtt], hi, mfp, *hash) == FAIL
2742-
|| ga_grow(&st->ga_match[mtt], 1) != OK)
2742+
|| ga_grow(&st->ga_match[mtt], 1) == FAIL)
27432743
{
27442744
// Out of memory! Just forget about the rest.
27452745
st->stop_searching = TRUE;

src/usercmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ uc_add_command(
10581058
// Extend the array unless we're replacing an existing command
10591059
if (cmp != 0)
10601060
{
1061-
if (ga_grow(gap, 1) != OK)
1061+
if (ga_grow(gap, 1) == FAIL)
10621062
goto fail;
10631063
if ((p = vim_strnsave(name, name_len)) == NULL)
10641064
goto fail;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1251,
698700
/**/
699701
1250,
700702
/**/

0 commit comments

Comments
 (0)