]>
Commit | Line | Data |
---|---|---|
0a7814d6 AG |
1 | To: vim-dev@vim.org |
2 | Subject: patch 7.1.074 | |
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.1.074 | |
11 | Problem: Crash when calling string() on a recurively nested List. | |
12 | Solution: Check result value for being NULL. (Yukihiro Nakadaira) | |
13 | Files: src/eval.c | |
14 | ||
15 | ||
16 | *** ../vim-7.1.073/src/eval.c Mon Aug 6 22:27:12 2007 | |
17 | --- src/eval.c Tue Aug 14 22:01:12 2007 | |
18 | *************** | |
19 | *** 6802,6808 **** | |
20 | * "numbuf" is used for a number. | |
21 | * Does not put quotes around strings, as ":echo" displays values. | |
22 | * When "copyID" is not NULL replace recursive lists and dicts with "...". | |
23 | ! * May return NULL; | |
24 | */ | |
25 | static char_u * | |
26 | echo_string(tv, tofree, numbuf, copyID) | |
27 | --- 6802,6808 ---- | |
28 | * "numbuf" is used for a number. | |
29 | * Does not put quotes around strings, as ":echo" displays values. | |
30 | * When "copyID" is not NULL replace recursive lists and dicts with "...". | |
31 | ! * May return NULL. | |
32 | */ | |
33 | static char_u * | |
34 | echo_string(tv, tofree, numbuf, copyID) | |
35 | *************** | |
36 | *** 6887,6893 **** | |
37 | * If the memory is allocated "tofree" is set to it, otherwise NULL. | |
38 | * "numbuf" is used for a number. | |
39 | * Puts quotes around strings, so that they can be parsed back by eval(). | |
40 | ! * May return NULL; | |
41 | */ | |
42 | static char_u * | |
43 | tv2string(tv, tofree, numbuf, copyID) | |
44 | --- 6887,6893 ---- | |
45 | * If the memory is allocated "tofree" is set to it, otherwise NULL. | |
46 | * "numbuf" is used for a number. | |
47 | * Puts quotes around strings, so that they can be parsed back by eval(). | |
48 | ! * May return NULL. | |
49 | */ | |
50 | static char_u * | |
51 | tv2string(tv, tofree, numbuf, copyID) | |
52 | *************** | |
53 | *** 14974,14979 **** | |
54 | --- 14974,14983 ---- | |
55 | ||
56 | p1 = tv2string(&(*(listitem_T **)s1)->li_tv, &tofree1, numbuf1, 0); | |
57 | p2 = tv2string(&(*(listitem_T **)s2)->li_tv, &tofree2, numbuf2, 0); | |
58 | + if (p1 == NULL) | |
59 | + p1 = (char_u *)""; | |
60 | + if (p2 == NULL) | |
61 | + p2 = (char_u *)""; | |
62 | if (item_compare_ic) | |
63 | res = STRICMP(p1, p2); | |
64 | else | |
65 | *************** | |
66 | *** 15463,15469 **** | |
67 | ||
68 | rettv->v_type = VAR_STRING; | |
69 | rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, 0); | |
70 | ! if (tofree == NULL) | |
71 | rettv->vval.v_string = vim_strsave(rettv->vval.v_string); | |
72 | } | |
73 | ||
74 | --- 15467,15474 ---- | |
75 | ||
76 | rettv->v_type = VAR_STRING; | |
77 | rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, 0); | |
78 | ! /* Make a copy if we have a value but it's not in allocate memory. */ | |
79 | ! if (rettv->vval.v_string != NULL && tofree == NULL) | |
80 | rettv->vval.v_string = vim_strsave(rettv->vval.v_string); | |
81 | } | |
82 | ||
83 | *************** | |
84 | *** 20167,20172 **** | |
85 | --- 20174,20180 ---- | |
86 | char_u buf[MSG_BUF_LEN]; | |
87 | char_u numbuf2[NUMBUFLEN]; | |
88 | char_u *tofree; | |
89 | + char_u *s; | |
90 | ||
91 | msg_puts((char_u *)"("); | |
92 | for (i = 0; i < argcount; ++i) | |
93 | *************** | |
94 | *** 20177,20186 **** | |
95 | msg_outnum((long)argvars[i].vval.v_number); | |
96 | else | |
97 | { | |
98 | ! trunc_string(tv2string(&argvars[i], &tofree, | |
99 | ! numbuf2, 0), buf, MSG_BUF_CLEN); | |
100 | ! msg_puts(buf); | |
101 | ! vim_free(tofree); | |
102 | } | |
103 | } | |
104 | msg_puts((char_u *)")"); | |
105 | --- 20185,20197 ---- | |
106 | msg_outnum((long)argvars[i].vval.v_number); | |
107 | else | |
108 | { | |
109 | ! s = tv2string(&argvars[i], &tofree, numbuf2, 0); | |
110 | ! if (s != NULL) | |
111 | ! { | |
112 | ! trunc_string(s, buf, MSG_BUF_CLEN); | |
113 | ! msg_puts(buf); | |
114 | ! vim_free(tofree); | |
115 | ! } | |
116 | } | |
117 | } | |
118 | msg_puts((char_u *)")"); | |
119 | *************** | |
120 | *** 20258,20271 **** | |
121 | char_u buf[MSG_BUF_LEN]; | |
122 | char_u numbuf2[NUMBUFLEN]; | |
123 | char_u *tofree; | |
124 | ||
125 | /* The value may be very long. Skip the middle part, so that we | |
126 | * have some idea how it starts and ends. smsg() would always | |
127 | * truncate it at the end. */ | |
128 | ! trunc_string(tv2string(fc.rettv, &tofree, numbuf2, 0), | |
129 | ! buf, MSG_BUF_CLEN); | |
130 | ! smsg((char_u *)_("%s returning %s"), sourcing_name, buf); | |
131 | ! vim_free(tofree); | |
132 | } | |
133 | msg_puts((char_u *)"\n"); /* don't overwrite this either */ | |
134 | ||
135 | --- 20269,20286 ---- | |
136 | char_u buf[MSG_BUF_LEN]; | |
137 | char_u numbuf2[NUMBUFLEN]; | |
138 | char_u *tofree; | |
139 | + char_u *s; | |
140 | ||
141 | /* The value may be very long. Skip the middle part, so that we | |
142 | * have some idea how it starts and ends. smsg() would always | |
143 | * truncate it at the end. */ | |
144 | ! s = tv2string(fc.rettv, &tofree, numbuf2, 0); | |
145 | ! if (s != NULL) | |
146 | ! { | |
147 | ! trunc_string(s, buf, MSG_BUF_CLEN); | |
148 | ! smsg((char_u *)_("%s returning %s"), sourcing_name, buf); | |
149 | ! vim_free(tofree); | |
150 | ! } | |
151 | } | |
152 | msg_puts((char_u *)"\n"); /* don't overwrite this either */ | |
153 | ||
154 | *** ../vim-7.1.073/src/version.c Tue Aug 14 22:15:53 2007 | |
155 | --- src/version.c Tue Aug 14 22:27:24 2007 | |
156 | *************** | |
157 | *** 668,669 **** | |
158 | --- 668,671 ---- | |
159 | { /* Add new patch number below this line */ | |
160 | + /**/ | |
161 | + 74, | |
162 | /**/ | |
163 | ||
164 | -- | |
165 | hundred-and-one symptoms of being an internet addict: | |
166 | 159. You get excited whenever discussing your hard drive. | |
167 | ||
168 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
169 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
170 | \\\ download, build and distribute -- http://www.A-A-P.org /// | |
171 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |