mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
No OOM error condition in cs_make_vim_style_matches()
Even though cs_reset() never returns anything different of `CS_SUCCESS` I can't change its return type to `void`. cs_reset() is used in the `cs_cmds` table.
This commit is contained in:
parent
aa32fbb838
commit
bd3587e91d
@ -1456,19 +1456,16 @@ static char *cs_make_vim_style_matches(char *fname, char *slno, char *search, ch
|
|||||||
* by new ones on the tag stack.
|
* by new ones on the tag stack.
|
||||||
*/
|
*/
|
||||||
char *buf;
|
char *buf;
|
||||||
int amt;
|
size_t amt;
|
||||||
|
|
||||||
if (search != NULL) {
|
if (search != NULL) {
|
||||||
amt =
|
amt = strlen(fname) + strlen(slno) + strlen(tagstr) + strlen(search) + 6;
|
||||||
(int)(strlen(fname) + strlen(slno) + strlen(tagstr) + strlen(search)+6);
|
buf = xmalloc(amt);
|
||||||
if ((buf = (char *)alloc(amt)) == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
(void)sprintf(buf, "%s\t%s\t%s;\"\t%s", tagstr, fname, slno, search);
|
(void)sprintf(buf, "%s\t%s\t%s;\"\t%s", tagstr, fname, slno, search);
|
||||||
} else {
|
} else {
|
||||||
amt = (int)(strlen(fname) + strlen(slno) + strlen(tagstr) + 5);
|
amt = strlen(fname) + strlen(slno) + strlen(tagstr) + 5;
|
||||||
if ((buf = (char *)alloc(amt)) == NULL)
|
buf = xmalloc(amt);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
(void)sprintf(buf, "%s\t%s\t%s;\"", tagstr, fname, slno);
|
(void)sprintf(buf, "%s\t%s\t%s;\"", tagstr, fname, slno);
|
||||||
}
|
}
|
||||||
@ -1669,10 +1666,9 @@ static void cs_fill_results(char *tagstr, int totmatches, int *nummatches_a, cha
|
|||||||
|
|
||||||
assert(totmatches > 0);
|
assert(totmatches > 0);
|
||||||
|
|
||||||
buf = (char *)alloc(CSREAD_BUFSIZE);
|
buf = xmalloc(CSREAD_BUFSIZE);
|
||||||
|
matches = xmalloc(sizeof(char *) * totmatches);
|
||||||
matches = (char **)alloc(sizeof(char *) * totmatches);
|
cntxts = xmalloc(sizeof(char *) * totmatches);
|
||||||
cntxts = (char **)alloc(sizeof(char *) * totmatches);
|
|
||||||
|
|
||||||
for (i = 0; i < csinfo_size; i++) {
|
for (i = 0; i < csinfo_size; i++) {
|
||||||
if (nummatches_a[i] < 1)
|
if (nummatches_a[i] < 1)
|
||||||
@ -1683,21 +1679,21 @@ static void cs_fill_results(char *tagstr, int totmatches, int *nummatches_a, cha
|
|||||||
&slno, &search)) == NULL)
|
&slno, &search)) == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
matches[totsofar] = cs_make_vim_style_matches(fullname, slno,
|
matches[totsofar] = cs_make_vim_style_matches(fullname, slno, search,
|
||||||
search, tagstr);
|
tagstr);
|
||||||
|
|
||||||
vim_free(fullname);
|
vim_free(fullname);
|
||||||
|
|
||||||
if (strcmp(cntx, "<global>") == 0)
|
if (strcmp(cntx, "<global>") == 0)
|
||||||
cntxts[totsofar] = NULL;
|
cntxts[totsofar] = NULL;
|
||||||
else
|
else {
|
||||||
/* note: if vim_strsave returns NULL, then the context
|
/* note: if vim_strsave returns NULL, then the context
|
||||||
* will be "<global>", which is misleading.
|
* will be "<global>", which is misleading.
|
||||||
*/
|
*/
|
||||||
cntxts[totsofar] = (char *)vim_strsave((char_u *)cntx);
|
cntxts[totsofar] = (char *)vim_strsave((char_u *)cntx);
|
||||||
|
}
|
||||||
|
|
||||||
if (matches[totsofar] != NULL)
|
totsofar++;
|
||||||
totsofar++;
|
|
||||||
|
|
||||||
} /* for all matches */
|
} /* for all matches */
|
||||||
|
|
||||||
@ -2080,9 +2076,9 @@ static int cs_reset(exarg_T *eap)
|
|||||||
return CSCOPE_SUCCESS;
|
return CSCOPE_SUCCESS;
|
||||||
|
|
||||||
/* malloc our db and ppath list */
|
/* malloc our db and ppath list */
|
||||||
dblist = (char **)alloc(csinfo_size * sizeof(char *));
|
dblist = xmalloc(csinfo_size * sizeof(char *));
|
||||||
pplist = (char **)alloc(csinfo_size * sizeof(char *));
|
pplist = xmalloc(csinfo_size * sizeof(char *));
|
||||||
fllist = (char **)alloc(csinfo_size * sizeof(char *));
|
fllist = xmalloc(csinfo_size * sizeof(char *));
|
||||||
|
|
||||||
for (i = 0; i < csinfo_size; i++) {
|
for (i = 0; i < csinfo_size; i++) {
|
||||||
dblist[i] = csinfo[i].fname;
|
dblist[i] = csinfo[i].fname;
|
||||||
|
Loading…
Reference in New Issue
Block a user