From 85100bb01dfebabf4b2557fd6d8a6041f83b0a76 Mon Sep 17 00:00:00 2001 From: Felipe Oliveira Carvalho Date: Sat, 31 May 2014 00:40:07 -0300 Subject: No OOM in concat_str() (few remaining cases) Also fixed the duplicated declaration (path.c and strings.c) --- src/nvim/eval.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b5efadb554..faa80ed0fa 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -11914,15 +11914,10 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) * concatenate the remainders. */ q = path_next_component(vim_ispathsep(*buf) ? buf + 1 : buf); if (*q != NUL) { - if (remain == NULL) - remain = vim_strsave(q - 1); - else { - cpy = concat_str(q - 1, remain); - if (cpy != NULL) { - free(remain); - remain = cpy; - } - } + cpy = remain; + remain = remain ? + concat_str(q - 1, remain) : (char_u *) xstrdup((char *)q - 1); + free(cpy); q[-1] = NUL; } @@ -11978,10 +11973,8 @@ static void f_resolve(typval_T *argvars, typval_T *rettv) || vim_ispathsep(p[2])))))) { /* Prepend "./". */ cpy = concat_str((char_u *)"./", p); - if (cpy != NULL) { - free(p); - p = cpy; - } + free(p); + p = cpy; } else if (!is_relative_to_current) { /* Strip leading "./". */ q = p; -- cgit