mirror of
https://github.com/neovim/neovim.git
synced 2025-09-22 03:08:27 +00:00
No OOM in home_replace_save()
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include "nvim/ex_docmd.h"
|
||||
#include "nvim/ex_getln.h"
|
||||
#include "nvim/fileio.h"
|
||||
#include "nvim/func_attr.h"
|
||||
#include "nvim/fold.h"
|
||||
#include "nvim/getchar.h"
|
||||
#include "nvim/indent.h"
|
||||
@@ -3278,20 +3279,17 @@ home_replace (
|
||||
|
||||
/*
|
||||
* Like home_replace, store the replaced string in allocated memory.
|
||||
* When something fails, NULL is returned.
|
||||
*/
|
||||
char_u *
|
||||
home_replace_save (
|
||||
buf_T *buf, /* when not NULL, check for help files */
|
||||
char_u *src /* input file name */
|
||||
)
|
||||
) FUNC_ATTR_NONNULL_RET
|
||||
{
|
||||
char_u *dst;
|
||||
|
||||
size_t len = 3; /* space for "~/" and trailing NUL */
|
||||
if (src != NULL) /* just in case */
|
||||
len += STRLEN(src);
|
||||
dst = xmalloc(len);
|
||||
char_u *dst = xmalloc(len);
|
||||
home_replace(buf, src, dst, (int)len, TRUE);
|
||||
return dst;
|
||||
}
|
||||
|
Reference in New Issue
Block a user