syntax: Fix V763: parameter always rewritten before being used

This is the result of malloc error handling elimination: push_current_state() 
used to (not) return OK depending on whether growing garray failed or not and 
this return was checked, if errorred out push_next_match() will simply return 
its argument unchanged.

Now when allocations are supposed to either always succeed or crash Neovim this 
check was returned, push_current_state() was stripped of its return value and 
moved out of if() condition, resulting in V763.
This commit is contained in:
ZyX
2017-07-04 17:39:26 +03:00
parent aaab5e3900
commit af1f17f1dc

View File

@@ -1666,8 +1666,9 @@ syn_current_attr (
* If we found a match after the last column, use it. * If we found a match after the last column, use it.
*/ */
if (next_match_idx >= 0 && next_match_col >= (int)current_col if (next_match_idx >= 0 && next_match_col >= (int)current_col
&& next_match_col != MAXCOL) && next_match_col != MAXCOL) {
(void)push_next_match(NULL); (void)push_next_match();
}
current_finished = TRUE; current_finished = TRUE;
current_state_stored = FALSE; current_state_stored = FALSE;
@@ -1985,9 +1986,10 @@ syn_current_attr (
* endless loop). */ * endless loop). */
GA_APPEND(int, &zero_width_next_ga, next_match_idx); GA_APPEND(int, &zero_width_next_ga, next_match_idx);
next_match_idx = -1; next_match_idx = -1;
} else } else {
cur_si = push_next_match(cur_si); cur_si = push_next_match();
found_match = TRUE; }
found_match = true;
} }
} }
} }
@@ -2167,9 +2169,10 @@ static int did_match_already(int idx, garray_T *gap)
/* /*
* Push the next match onto the stack. * Push the next match onto the stack.
*/ */
static stateitem_T *push_next_match(stateitem_T *cur_si) static stateitem_T *push_next_match(void)
{ {
synpat_T *spp; stateitem_T *cur_si;
synpat_T *spp;
int save_flags; int save_flags;
spp = &(SYN_ITEMS(syn_block)[next_match_idx]); spp = &(SYN_ITEMS(syn_block)[next_match_idx]);