No OOM error in call_shell() and read_string()

This commit is contained in:
Felipe Oliveira Carvalho 2014-04-21 19:36:36 -03:00 committed by Thiago de Arruda
parent 28b03dd190
commit e76d146029

View File

@ -1234,8 +1234,7 @@ int call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg)
if (ecmd == NULL)
ecmd = cmd;
}
ncmd = alloc((unsigned)(STRLEN(ecmd) + STRLEN(p_sxq) * 2 + 1));
if (ncmd != NULL) {
ncmd = xmalloc(STRLEN(ecmd) + STRLEN(p_sxq) * 2 + 1);
STRCPY(ncmd, p_sxq);
STRCAT(ncmd, ecmd);
/* When 'shellxquote' is ( append ).
@ -1245,8 +1244,7 @@ int call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg)
: p_sxq);
retval = os_call_shell(ncmd, opts, extra_shell_arg);
vim_free(ncmd);
} else
retval = -1;
if (ecmd != cmd)
vim_free(ecmd);
}
@ -1432,16 +1430,14 @@ time_t get8ctime(FILE *fd)
/*
* Read a string of length "cnt" from "fd" into allocated memory.
* Returns NULL when out of memory or unable to read that many bytes.
* Returns NULL when unable to read that many bytes.
*/
char_u *read_string(FILE *fd, int cnt)
{
char_u *str;
int i;
int c;
/* allocate memory */
str = alloc((unsigned)cnt + 1);
char_u *str = xmallocz(cnt);
/* Read the string. Quit when running into the EOF. */
for (i = 0; i < cnt; ++i) {
c = getc(fd);