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 | 0f7ad2be3721c35b3e1c63c9613e8045011ecca2 (patch) | |
tree | 4914bc0c55e179d5f041cc23139afa31d87898b9 /src | |
parent | f6a2bbc3d65772cd1c97c99a16ce1b5fbb83c1e0 (diff) | |
download | vim-0f7ad2be3721c35b3e1c63c9613e8045011ecca2.tar.gz |
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')
-rw-r--r-- | src/memline.c | 9 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/memline.c b/src/memline.c index 8201a012..2a2426d6 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, ","); /* diff --git a/src/version.c b/src/version.c index 9f5b06cc..46565870 100644 --- a/src/version.c +++ b/src/version.c @@ -715,6 +715,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 349, +/**/ 348, /**/ 347, |