]>
Commit | Line | Data |
---|---|---|
f3c378e8 AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 7.0.082 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=ISO-8859-1 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.0.082 | |
11 | Problem: Calling a function that waits for input may cause List and | |
12 | Dictionary arguments to be freed by the garbage collector. | |
13 | Solution: Keep a list of all arguments to internal functions. | |
14 | Files: src/eval.c | |
15 | ||
16 | ||
17 | *** ../vim-7.0.081/src/eval.c Sat Sep 2 13:45:01 2006 | |
18 | --- src/eval.c Sun Sep 3 15:36:10 2006 | |
19 | *************** | |
20 | *** 248,253 **** | |
21 | --- 248,264 ---- | |
22 | }; | |
23 | ||
24 | /* | |
25 | + * Struct used to make a list of all arguments used in internal functions. | |
26 | + */ | |
27 | + typedef struct av_list_item_S av_list_item_T; | |
28 | + struct av_list_item_S { | |
29 | + av_list_item_T *avl_next; | |
30 | + typval_T *avl_argvars; | |
31 | + }; | |
32 | + | |
33 | + av_list_item_T *argvars_list = NULL; | |
34 | + | |
35 | + /* | |
36 | * Info used by a ":for" loop. | |
37 | */ | |
38 | typedef struct | |
39 | *************** | |
40 | *** 6058,6063 **** | |
41 | --- 6069,6075 ---- | |
42 | int i; | |
43 | funccall_T *fc; | |
44 | int did_free = FALSE; | |
45 | + av_list_item_T *av; | |
46 | #ifdef FEAT_WINDOWS | |
47 | tabpage_T *tp; | |
48 | #endif | |
49 | *************** | |
50 | *** 6094,6099 **** | |
51 | --- 6106,6116 ---- | |
52 | set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID); | |
53 | } | |
54 | ||
55 | + /* arguments for internal functions */ | |
56 | + for (av = argvars_list; av != NULL; av = av->avl_next) | |
57 | + for (i = 0; av->avl_argvars[i].v_type != VAR_UNKNOWN; ++i) | |
58 | + set_ref_in_item(&av->avl_argvars[i], copyID); | |
59 | + | |
60 | /* | |
61 | * 2. Go through the list of dicts and free items without the copyID. | |
62 | */ | |
63 | *************** | |
64 | *** 7537,7545 **** | |
65 | --- 7554,7574 ---- | |
66 | error = ERROR_TOOMANY; | |
67 | else | |
68 | { | |
69 | + av_list_item_T av_list_item; | |
70 | + | |
71 | + /* Add the arguments to the "argvars_list" to avoid the | |
72 | + * garbage collector not seeing them. This isn't needed | |
73 | + * for user functions, because the arguments are available | |
74 | + * in the a: hashtab. */ | |
75 | + av_list_item.avl_argvars = argvars; | |
76 | + av_list_item.avl_next = argvars_list; | |
77 | + argvars_list = &av_list_item; | |
78 | + | |
79 | argvars[argcount].v_type = VAR_UNKNOWN; | |
80 | functions[i].f_func(argvars, rettv); | |
81 | error = ERROR_NONE; | |
82 | + | |
83 | + argvars_list = av_list_item.avl_next; | |
84 | } | |
85 | } | |
86 | } | |
87 | *** ../vim-7.0.081/src/version.c Sat Sep 2 17:58:36 2006 | |
88 | --- src/version.c Sun Sep 3 15:35:16 2006 | |
89 | *************** | |
90 | *** 668,669 **** | |
91 | --- 668,671 ---- | |
92 | { /* Add new patch number below this line */ | |
93 | + /**/ | |
94 | + 82, | |
95 | /**/ | |
96 | ||
97 | -- | |
98 | Just think of all the things we haven't thought of yet. | |
99 | ||
100 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
101 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
102 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
103 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |