Patch 8.1.2372
Problem: VMS: failing realloc leaks memory. (Chakshu Gupta)
Solution: Free the memory. (partly fixes #5292)
Files: src/os_vms.c
*** ../vim-8.1.2371/src/os_vms.c 2019-11-30 22:38:11.913921804 +0100
--- src/os_vms.c 2019-11-30 22:56:56.500823914 +0100
***************
*** 404,415 ****
return 1;
}
if (--vms_match_free == 0) {
/* add more space to store matches */
vms_match_alloced += EXPL_ALLOC_INC;
! vms_fmatch = vim_realloc(vms_fmatch,
sizeof(char **) * vms_match_alloced);
if (!vms_fmatch)
return 0;
vms_match_free = EXPL_ALLOC_INC;
}
vms_fmatch[vms_match_num] = vim_strsave((char_u *)name);
--- 404,420 ----
return 1;
}
if (--vms_match_free == 0) {
+ char_u **old_vms_fmatch = vms_fmatch;
+
/* add more space to store matches */
vms_match_alloced += EXPL_ALLOC_INC;
! vms_fmatch = vim_realloc(old_vms_fmatch,
sizeof(char **) * vms_match_alloced);
if (!vms_fmatch)
+ {
+ vim_free(old_vms_fmatch);
return 0;
+ }
vms_match_free = EXPL_ALLOC_INC;
}
vms_fmatch[vms_match_num] = vim_strsave((char_u *)name);
***************
*** 489,498 ****
/* allocate memory for pointers */
if (--files_free < 1)
{
files_alloced += EXPL_ALLOC_INC;
! *file = vim_realloc(*file, sizeof(char_u **) * files_alloced);
if (*file == NULL)
{
*file = (char_u **)"";
*num_file = 0;
return(FAIL);
--- 494,506 ----
/* allocate memory for pointers */
if (--files_free < 1)
{
+ char_u **old_file = *file;
+
files_alloced += EXPL_ALLOC_INC;
! *file = vim_realloc(old_file, sizeof(char_u **) * files_alloced);
if (*file == NULL)
{
+ vim_free(old_file);
*file = (char_u **)"";
*num_file = 0;
return(FAIL);
*** ../vim-8.1.2371/src/version.c 2019-11-30 22:47:42.659331167 +0100
--- src/version.c 2019-11-30 22:57:34.828650529 +0100
***************
*** 744,745 ****
--- 744,747 ----
{ /* Add new patch number below this line */
+ /**/
+ 2372,
/**/
--
hundred-and-one symptoms of being an internet addict:
159. You get excited whenever discussing your hard drive.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///