diff options
author | Bram Moolenaar <Bram@vim.org> | 2011-10-26 11:44:18 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2011-10-26 11:44:18 +0200 |
commit | f541c36a8cf24c59bcc0d950776697230b3b8baf (patch) | |
tree | 333fdb4acef14e4ef90d1871a43ed2e6fc9eac54 /src/memline.c | |
parent | 79739e163ba7f4b8fe1ad8374d24521b2e595331 (diff) | |
download | vim-git-f541c36a8cf24c59bcc0d950776697230b3b8baf.tar.gz |
updated for version 7.3.349v7.3.349
Problem: When running out of memory during startup trying to open a
swapfile will loop forever.
Solution: Let findswapname() set dirp to NULL if out of memory.
Diffstat (limited to 'src/memline.c')
-rw-r--r-- | src/memline.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/memline.c b/src/memline.c index 8201a0120..2a2426d67 100644 --- a/src/memline.c +++ b/src/memline.c @@ -621,6 +621,8 @@ ml_setname(buf) break; fname = findswapname(buf, &dirp, mfp->mf_fname); /* alloc's fname */ + if (dirp == NULL) /* out of memory */ + break; if (fname == NULL) /* no file name found for this dir */ continue; @@ -744,6 +746,8 @@ ml_open_file(buf) * and creating it, another Vim creates the file. In that case the * creation will fail and we will use another directory. */ fname = findswapname(buf, &dirp, NULL); /* allocates fname */ + if (dirp == NULL) + break; /* out of memory */ if (fname == NULL) continue; if (mf_open_file(mfp, fname) == OK) /* consumes fname! */ @@ -4114,6 +4118,7 @@ do_swapexists(buf, fname) * * Several names are tried to find one that does not exist * Returns the name in allocated memory or NULL. + * When out of memory "dirp" is set to NULL. * * Note: If BASENAMELEN is not correct, you will get error messages for * not being able to open the swap or undo file @@ -4157,7 +4162,9 @@ findswapname(buf, dirp, old_fname) * First allocate some memory to put the directory name in. */ dir_name = alloc((unsigned)STRLEN(*dirp) + 1); - if (dir_name != NULL) + if (dir_name == NULL) + *dirp = NULL; + else (void)copy_option_part(dirp, dir_name, 31000, ","); /* |