if (msg_col >= endcol) // output at least one space
endcol = msg_col + 1;
- if (Columns <= endcol) // avoid hang for tiny window
- endcol = Columns - 1;
+ if (Columns <= (long)endcol) // avoid hang for tiny window
+ endcol = (int)(Columns - 1);
msg_advance(endcol);
}
}
- fuzzy_indices_data = (int *)fuzzy_indices.ga_data;
- qsort(fuzzy_indices_data, fuzzy_indices.ga_len, sizeof(int), compare_scores);
+ // prevent qsort from deref NULL pointer
+ if (fuzzy_indices.ga_len > 0)
+ {
+ fuzzy_indices_data = (int *)fuzzy_indices.ga_data;
+ qsort(fuzzy_indices_data, fuzzy_indices.ga_len, sizeof(int), compare_scores);
+
+ sorted_matches = (char_u **)alloc(sizeof(char_u *) * fuzzy_indices.ga_len);
+ for (i = 0; i < fuzzy_indices.ga_len; ++i)
+ sorted_matches[i] = vim_strsave(matches[fuzzy_indices_data[i]]);
- sorted_matches = (char_u **)alloc(sizeof(char_u *) * fuzzy_indices.ga_len);
- for (i = 0; i < fuzzy_indices.ga_len; ++i)
- sorted_matches[i] = vim_strsave(matches[fuzzy_indices_data[i]]);
+ FreeWild(num_matches, matches);
+ matches = sorted_matches;
+ num_matches = fuzzy_indices.ga_len;
+ }
- FreeWild(num_matches, matches);
- matches = sorted_matches;
- num_matches = fuzzy_indices.ga_len;
vim_free(compl_fuzzy_scores);
ga_clear(&fuzzy_indices);
}
if (round) // round off indent
{
- i = count / sw_val; // number of 'shiftwidth' rounded down
- j = count % sw_val; // extra spaces
+ i = trim_to_int(count) / sw_val; // number of 'shiftwidth' rounded down
+ j = trim_to_int(count) % sw_val; // extra spaces
if (j && left) // first remove extra spaces
--amount;
if (left)
l = (int)STRLEN(buf);
vim_snprintf((char *)buf + l, MAXPATHL - l, "/spell");
if (filewritable(buf) != 2)
- vim_mkdir(buf, 0755);
+ {
+ if (vim_mkdir(buf, 0755) != 0)
+ {
+ vim_free(buf);
+ return;
+ }
+ }
l = (int)STRLEN(buf);
vim_snprintf((char *)buf + l, MAXPATHL - l,
if (msg_col >= endcol) // output at least one space
endcol = msg_col + 1;
- if (Columns <= endcol) // avoid hang for tiny window
- endcol = Columns - 1;
+ if (Columns <= (long)endcol) // avoid hang for tiny window
+ endcol = (int)(Columns - 1);
msg_advance(endcol);
if (SYN_CLSTR(curwin->w_s)[id].scl_list != NULL)