Mercurial > vim
comparison src/os_vms.c @ 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 | e3785af3ba0f |
children | 44b855153d8e |
comparison
equal
deleted
inserted
replaced
18764:4105578578ec | 18765:1130f8309f67 |
---|---|
402 for (i = 0; i<vms_match_num; i++) { | 402 for (i = 0; i<vms_match_num; i++) { |
403 if (0 == STRCMP((char_u *)name,vms_fmatch[i])) | 403 if (0 == STRCMP((char_u *)name,vms_fmatch[i])) |
404 return 1; | 404 return 1; |
405 } | 405 } |
406 if (--vms_match_free == 0) { | 406 if (--vms_match_free == 0) { |
407 char_u **old_vms_fmatch = vms_fmatch; | |
408 | |
407 /* add more space to store matches */ | 409 /* add more space to store matches */ |
408 vms_match_alloced += EXPL_ALLOC_INC; | 410 vms_match_alloced += EXPL_ALLOC_INC; |
409 vms_fmatch = vim_realloc(vms_fmatch, | 411 vms_fmatch = vim_realloc(old_vms_fmatch, |
410 sizeof(char **) * vms_match_alloced); | 412 sizeof(char **) * vms_match_alloced); |
411 if (!vms_fmatch) | 413 if (!vms_fmatch) |
414 { | |
415 vim_free(old_vms_fmatch); | |
412 return 0; | 416 return 0; |
417 } | |
413 vms_match_free = EXPL_ALLOC_INC; | 418 vms_match_free = EXPL_ALLOC_INC; |
414 } | 419 } |
415 vms_fmatch[vms_match_num] = vim_strsave((char_u *)name); | 420 vms_fmatch[vms_match_num] = vim_strsave((char_u *)name); |
416 | 421 |
417 ++vms_match_num; | 422 ++vms_match_num; |
487 continue; | 492 continue; |
488 | 493 |
489 /* allocate memory for pointers */ | 494 /* allocate memory for pointers */ |
490 if (--files_free < 1) | 495 if (--files_free < 1) |
491 { | 496 { |
497 char_u **old_file = *file; | |
498 | |
492 files_alloced += EXPL_ALLOC_INC; | 499 files_alloced += EXPL_ALLOC_INC; |
493 *file = vim_realloc(*file, sizeof(char_u **) * files_alloced); | 500 *file = vim_realloc(old_file, sizeof(char_u **) * files_alloced); |
494 if (*file == NULL) | 501 if (*file == NULL) |
495 { | 502 { |
503 vim_free(old_file); | |
496 *file = (char_u **)""; | 504 *file = (char_u **)""; |
497 *num_file = 0; | 505 *num_file = 0; |
498 return(FAIL); | 506 return(FAIL); |
499 } | 507 } |
500 files_free = EXPL_ALLOC_INC; | 508 files_free = EXPL_ALLOC_INC; |