mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 14:28:18 +00:00
No OOM in concat_str() (few remaining cases)
Also fixed the duplicated declaration (path.c and strings.c)
This commit is contained in:
@@ -11914,15 +11914,10 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
|
|||||||
* concatenate the remainders. */
|
* concatenate the remainders. */
|
||||||
q = path_next_component(vim_ispathsep(*buf) ? buf + 1 : buf);
|
q = path_next_component(vim_ispathsep(*buf) ? buf + 1 : buf);
|
||||||
if (*q != NUL) {
|
if (*q != NUL) {
|
||||||
if (remain == NULL)
|
cpy = remain;
|
||||||
remain = vim_strsave(q - 1);
|
remain = remain ?
|
||||||
else {
|
concat_str(q - 1, remain) : (char_u *) xstrdup((char *)q - 1);
|
||||||
cpy = concat_str(q - 1, remain);
|
free(cpy);
|
||||||
if (cpy != NULL) {
|
|
||||||
free(remain);
|
|
||||||
remain = cpy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
q[-1] = NUL;
|
q[-1] = NUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11978,10 +11973,8 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
|
|||||||
|| vim_ispathsep(p[2])))))) {
|
|| vim_ispathsep(p[2])))))) {
|
||||||
/* Prepend "./". */
|
/* Prepend "./". */
|
||||||
cpy = concat_str((char_u *)"./", p);
|
cpy = concat_str((char_u *)"./", p);
|
||||||
if (cpy != NULL) {
|
|
||||||
free(p);
|
free(p);
|
||||||
p = cpy;
|
p = cpy;
|
||||||
}
|
|
||||||
} else if (!is_relative_to_current) {
|
} else if (!is_relative_to_current) {
|
||||||
/* Strip leading "./". */
|
/* Strip leading "./". */
|
||||||
q = p;
|
q = p;
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include "nvim/fileio.h"
|
#include "nvim/fileio.h"
|
||||||
#include "nvim/func_attr.h"
|
#include "nvim/func_attr.h"
|
||||||
#include "nvim/fold.h"
|
#include "nvim/fold.h"
|
||||||
|
#include "nvim/func_attr.h"
|
||||||
#include "nvim/getchar.h"
|
#include "nvim/getchar.h"
|
||||||
#include "nvim/mark.h"
|
#include "nvim/mark.h"
|
||||||
#include "nvim/mbyte.h"
|
#include "nvim/mbyte.h"
|
||||||
@@ -514,7 +515,6 @@ int has_non_ascii(char_u *s)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Concatenate two strings and return the result in allocated memory.
|
* Concatenate two strings and return the result in allocated memory.
|
||||||
* Returns NULL when out of memory.
|
|
||||||
*/
|
*/
|
||||||
char_u *concat_str(char_u *str1, char_u *str2) FUNC_ATTR_NONNULL_RET
|
char_u *concat_str(char_u *str1, char_u *str2) FUNC_ATTR_NONNULL_RET
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user