Skip to content

Commit 9e50ec2

Browse files
committed
updated for version 7.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.
1 parent 69f47b4 commit 9e50ec2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/memline.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,8 @@ ml_setname(buf)
621621
break;
622622
fname = findswapname(buf, &dirp, mfp->mf_fname);
623623
/* alloc's fname */
624+
if (dirp == NULL) /* out of memory */
625+
break;
624626
if (fname == NULL) /* no file name found for this dir */
625627
continue;
626628

@@ -744,6 +746,8 @@ ml_open_file(buf)
744746
* and creating it, another Vim creates the file. In that case the
745747
* creation will fail and we will use another directory. */
746748
fname = findswapname(buf, &dirp, NULL); /* allocates fname */
749+
if (dirp == NULL)
750+
break; /* out of memory */
747751
if (fname == NULL)
748752
continue;
749753
if (mf_open_file(mfp, fname) == OK) /* consumes fname! */
@@ -4114,6 +4118,7 @@ do_swapexists(buf, fname)
41144118
*
41154119
* Several names are tried to find one that does not exist
41164120
* Returns the name in allocated memory or NULL.
4121+
* When out of memory "dirp" is set to NULL.
41174122
*
41184123
* Note: If BASENAMELEN is not correct, you will get error messages for
41194124
* not being able to open the swap or undo file
@@ -4157,7 +4162,9 @@ findswapname(buf, dirp, old_fname)
41574162
* First allocate some memory to put the directory name in.
41584163
*/
41594164
dir_name = alloc((unsigned)STRLEN(*dirp) + 1);
4160-
if (dir_name != NULL)
4165+
if (dir_name == NULL)
4166+
*dirp = NULL;
4167+
else
41614168
(void)copy_option_part(dirp, dir_name, 31000, ",");
41624169

41634170
/*

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@ static char *(features[]) =
714714

715715
static int included_patches[] =
716716
{ /* Add new patch number below this line */
717+
/**/
718+
349,
717719
/**/
718720
348,
719721
/**/

0 commit comments

Comments
 (0)