Mercurial > vim
changeset 18765:1130f8309f67 v8.1.2372
patch 8.1.2372: VMS: failing realloc leaks memory
Commit: https://github.com/vim/vim/commit/9625d3d92d93be52f5d89a57b27ba2400e0fc6d2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 30 22:57:53 2019 +0100
patch 8.1.2372: VMS: failing realloc leaks memory
Problem: VMS: failing realloc leaks memory. (Chakshu Gupta)
Solution: Free the memory. (partly fixes https://github.com/vim/vim/issues/5292)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 30 Nov 2019 23:00:05 +0100 |
parents | 4105578578ec |
children | 3cc0ddf2abd0 |
files | src/os_vms.c src/version.c |
diffstat | 2 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/os_vms.c +++ b/src/os_vms.c @@ -404,12 +404,17 @@ vms_wproc(char *name, int val) 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(vms_fmatch, + 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,10 +494,13 @@ mch_expand_wildcards(int num_pat, char_u /* allocate memory for pointers */ if (--files_free < 1) { + char_u **old_file = *file; + files_alloced += EXPL_ALLOC_INC; - *file = vim_realloc(*file, sizeof(char_u **) * files_alloced); + *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);