aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-05-30 23:53:03 -0300
committerFelipe Oliveira Carvalho <felipekde@gmail.com>2014-06-16 01:36:32 -0300
commita26a1697c7b3447ebb21acb1f0e6bae16d80e409 (patch)
treecf37599ac3e68459037b35ab376323aa9ce8ad07 /src/nvim/ex_docmd.c
parentcca66742ebbc13a88b809173b2362245c2ba6a55 (diff)
downloadrneovim-a26a1697c7b3447ebb21acb1f0e6bae16d80e409.tar.gz
rneovim-a26a1697c7b3447ebb21acb1f0e6bae16d80e409.tar.bz2
rneovim-a26a1697c7b3447ebb21acb1f0e6bae16d80e409.zip
No OOM in home_replace_save()
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 66a4ac71c3..6e02c741eb 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -7909,8 +7909,7 @@ makeopens (
return FAIL;
} else if (ssop_flags & SSOP_CURDIR) {
sname = home_replace_save(NULL, globaldir != NULL ? globaldir : dirnow);
- if (sname == NULL
- || fputs("cd ", fd) < 0
+ if (fputs("cd ", fd) < 0
|| ses_put_fname(fd, sname, &ssop_flags) == FAIL
|| put_eol(fd) == FAIL) {
free(sname);
@@ -8535,17 +8534,13 @@ static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp)
* Write a file name to the session file.
* Takes care of the "slash" option in 'sessionoptions' and escapes special
* characters.
- * Returns FAIL if writing fails or out of memory.
+ * Returns FAIL if writing fails.
*/
static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp)
{
- char_u *sname;
char_u *p;
- int retval = OK;
- sname = home_replace_save(NULL, name);
- if (sname == NULL)
- return FAIL;
+ char_u *sname = home_replace_save(NULL, name);
if (*flagp & SSOP_SLASH) {
/* change all backslashes to forward slashes */
@@ -8559,11 +8554,13 @@ static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp)
free(sname);
/* write the result */
- if (fputs((char *)p, fd) < 0)
- retval = FAIL;
+ if (fputs((char *)p, fd) < 0) {
+ free(p);
+ return FAIL;
+ }
free(p);
- return retval;
+ return OK;
}
/*