]>
Commit | Line | Data |
---|---|---|
05649561 AG |
1 | To: vim-dev@vim.org |
2 | Subject: Patch 6.2.232 | |
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 6.2.232 | |
11 | Problem: ":python vim.command('python print 2*2')" crashes Vim. (Eugene | |
12 | Minkovskii) | |
13 | Solution: Disallow executing a Python command recursively and give an error | |
14 | message. | |
15 | Files: src/if_python.c | |
16 | ||
17 | ||
18 | *** ../vim-6.2.231/src/if_python.c Mon Dec 29 21:14:00 2003 | |
19 | --- src/if_python.c Tue Feb 3 19:41:48 2004 | |
20 | *************** | |
21 | *** 451,470 **** | |
22 | return -1; | |
23 | } | |
24 | ||
25 | ! /* External interface | |
26 | */ | |
27 | static void | |
28 | DoPythonCommand(exarg_T *eap, const char *cmd) | |
29 | { | |
30 | #if defined(MACOS) && !defined(MACOS_X_UNIX) | |
31 | GrafPtr oldPort; | |
32 | GetPort (&oldPort); | |
33 | /* Check if the Python library is available */ | |
34 | if ( (Ptr) PyMac_Initialize == (Ptr) kUnresolvedCFragSymbolAddress) | |
35 | ! return; | |
36 | #endif | |
37 | if (Python_Init()) | |
38 | ! return; | |
39 | ||
40 | RangeStart = eap->line1; | |
41 | RangeEnd = eap->line2; | |
42 | --- 451,480 ---- | |
43 | return -1; | |
44 | } | |
45 | ||
46 | ! /* | |
47 | ! * External interface | |
48 | */ | |
49 | static void | |
50 | DoPythonCommand(exarg_T *eap, const char *cmd) | |
51 | { | |
52 | + static int recursive = 0; | |
53 | + | |
54 | + if (recursive) | |
55 | + { | |
56 | + EMSG(_("E659: Cannot invoke Python recursively")); | |
57 | + return; | |
58 | + } | |
59 | + ++recursive; | |
60 | + | |
61 | #if defined(MACOS) && !defined(MACOS_X_UNIX) | |
62 | GrafPtr oldPort; | |
63 | GetPort (&oldPort); | |
64 | /* Check if the Python library is available */ | |
65 | if ( (Ptr) PyMac_Initialize == (Ptr) kUnresolvedCFragSymbolAddress) | |
66 | ! goto theend; | |
67 | #endif | |
68 | if (Python_Init()) | |
69 | ! goto theend; | |
70 | ||
71 | RangeStart = eap->line1; | |
72 | RangeEnd = eap->line2; | |
73 | *************** | |
74 | *** 477,482 **** | |
75 | --- 487,495 ---- | |
76 | #if defined(MACOS) && !defined(MACOS_X_UNIX) | |
77 | SetPort (oldPort); | |
78 | #endif | |
79 | + | |
80 | + theend: | |
81 | + --recursive; | |
82 | } | |
83 | ||
84 | /* | |
85 | *** ../vim-6.2.231/src/version.c Tue Feb 3 17:25:35 2004 | |
86 | --- src/version.c Tue Feb 3 19:58:11 2004 | |
87 | *************** | |
88 | *** 639,640 **** | |
89 | --- 639,642 ---- | |
90 | { /* Add new patch number below this line */ | |
91 | + /**/ | |
92 | + 232, | |
93 | /**/ | |
94 | ||
95 | -- | |
96 | To define recursion, we must first define recursion. | |
97 | ||
98 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
99 | /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
100 | \\\ Project leader for A-A-P -- http://www.A-A-P.org /// | |
101 | \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html /// |