comparison src/cmdexpand.c @ 19057:463b6fad54e9 v8.2.0089

patch 8.2.0089: crash when running out of memory in :setfiletype completion Commit: https://github.com/vim/vim/commit/f0f8055102c264b1d0c0a79bf742dc126fb447b9 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 5 22:05:49 2020 +0100 patch 8.2.0089: crash when running out of memory in :setfiletype completion Problem: Crash when running out of memory in :setfiletype completion. Solution: Do not allocate memory. (Dominique Pelle, closes https://github.com/vim/vim/issues/5438)
author Bram Moolenaar <Bram@vim.org>
date Sun, 05 Jan 2020 22:15:33 +0100
parents cec4da73951a
children 568cce19fd2b
comparison
equal deleted inserted replaced
19056:369253646046 19057:463b6fad54e9
2631 WILD_SILENT|expand_options) != FAIL && num_p > 0) 2631 WILD_SILENT|expand_options) != FAIL && num_p > 0)
2632 { 2632 {
2633 ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT|expand_options); 2633 ExpandEscape(&xpc, buf, num_p, p, WILD_SILENT|expand_options);
2634 2634
2635 if (ga_grow(ga, num_p) == OK) 2635 if (ga_grow(ga, num_p) == OK)
2636 { 2636 // take over the pointers and put them in "ga"
2637 for (i = 0; i < num_p; ++i) 2637 for (i = 0; i < num_p; ++i)
2638 { 2638 {
2639 ((char_u **)ga->ga_data)[ga->ga_len] = 2639 ((char_u **)ga->ga_data)[ga->ga_len] = p[i];
2640 vim_strnsave(p[i], (int)STRLEN(p[i]));
2641 ++ga->ga_len; 2640 ++ga->ga_len;
2642 } 2641 }
2643 } 2642 vim_free(p);
2644
2645 FreeWild(num_p, p);
2646 } 2643 }
2647 } 2644 }
2648 } 2645 }
2649 2646
2650 vim_free(buf); 2647 vim_free(buf);