1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
11 Problem: Processing new Esperanto spell file fails and crashes Vim.
13 Solution: When running out of memory give an error. Handle '?' in
14 COMPOUNDRULE properly.
18 *** ../vim-7.3.108/src/spell.c 2010-12-17 18:06:00.000000000 +0100
19 --- src/spell.c 2011-02-01 13:43:52.000000000 +0100
24 /* Add all flags to "sl_compallflags". */
25 ! if (vim_strchr((char_u *)"+*[]/", c) == NULL
26 && !byte_in_str(slang->sl_compallflags, c))
32 /* Add all flags to "sl_compallflags". */
33 ! if (vim_strchr((char_u *)"?*+[]/", c) == NULL
34 && !byte_in_str(slang->sl_compallflags, c))
39 /* Copy flag to "sl_comprules", unless we run into a wildcard. */
42 ! if (c == '+' || c == '*')
44 vim_free(slang->sl_comprules);
45 slang->sl_comprules = NULL;
47 /* Copy flag to "sl_comprules", unless we run into a wildcard. */
50 ! if (c == '?' || c == '+' || c == '*')
52 vim_free(slang->sl_comprules);
53 slang->sl_comprules = NULL;
57 else /* normal char, "[abc]" and '*' are copied as-is */
59 ! if (c == '+' || c == '~')
60 ! *pp++ = '\\'; /* "a+" becomes "a\+" */
63 pp += mb_char2bytes(c, pp);
66 else /* normal char, "[abc]" and '*' are copied as-is */
68 ! if (c == '?' || c == '+' || c == '~')
69 ! *pp++ = '\\'; /* "a?" becomes "a\?", "a+" becomes "a\+" */
72 pp += mb_char2bytes(c, pp);
77 sblock_T *si_blocks; /* memory blocks used */
78 long si_blocks_cnt; /* memory blocks allocated */
79 + int si_did_emsg; /* TRUE when ran out of memory */
81 long si_compress_cnt; /* words to add before lowering
83 wordnode_T *si_first_free; /* List of nodes that have been freed during
87 else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2))
89 ! /* Concatenate this string to previously defined ones, using a
90 ! * slash to separate them. */
91 ! l = (int)STRLEN(items[1]) + 1;
92 ! if (compflags != NULL)
93 ! l += (int)STRLEN(compflags) + 1;
94 ! p = getroom(spin, l, FALSE);
97 if (compflags != NULL)
99 ! STRCPY(p, compflags);
102 - STRCAT(p, items[1]);
106 else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2)
109 else if (is_aff_rule(items, itemcnt, "COMPOUNDRULE", 2))
111 ! /* Don't use the first rule if it is a number. */
112 ! if (compflags != NULL || *skipdigits(items[1]) != NUL)
114 + /* Concatenate this string to previously defined ones,
115 + * using a slash to separate them. */
116 + l = (int)STRLEN(items[1]) + 1;
117 if (compflags != NULL)
118 + l += (int)STRLEN(compflags) + 1;
119 + p = getroom(spin, l, FALSE);
122 ! if (compflags != NULL)
124 ! STRCPY(p, compflags);
127 ! STRCAT(p, items[1]);
132 else if (is_aff_rule(items, itemcnt, "COMPOUNDWORDMAX", 2)
136 for (p = compflags; *p != NUL; )
138 ! if (vim_strchr((char_u *)"/*+[]", *p) != NULL)
139 /* Copy non-flag characters directly. */
144 for (p = compflags; *p != NUL; )
146 ! if (vim_strchr((char_u *)"/?*+[]", *p) != NULL)
147 /* Copy non-flag characters directly. */
153 check_renumber(spin);
154 id = spin->si_newcompID--;
155 ! } while (vim_strchr((char_u *)"/+*[]\\-^", id) != NULL);
157 hash_add(&aff->af_comp, ci->ci_key);
161 check_renumber(spin);
162 id = spin->si_newcompID--;
163 ! } while (vim_strchr((char_u *)"/?*+[]\\-^", id) != NULL);
165 hash_add(&aff->af_comp, ci->ci_key);
170 if (bl == NULL || bl->sb_used + len > SBLOCKSIZE)
172 ! /* Allocate a block of memory. This is not freed until much later. */
173 ! bl = (sblock_T *)alloc_clear((unsigned)(sizeof(sblock_T) + SBLOCKSIZE));
176 bl->sb_next = spin->si_blocks;
177 spin->si_blocks = bl;
181 if (bl == NULL || bl->sb_used + len > SBLOCKSIZE)
183 ! if (len >= SBLOCKSIZE)
186 ! /* Allocate a block of memory. It is not freed until much later. */
187 ! bl = (sblock_T *)alloc_clear(
188 ! (unsigned)(sizeof(sblock_T) + SBLOCKSIZE));
191 + if (!spin->si_did_emsg)
193 + EMSG(_("E845: Insufficient memory, word list will be incomplete"));
194 + spin->si_did_emsg = TRUE;
198 bl->sb_next = spin->si_blocks;
199 spin->si_blocks = bl;
206 * Make a copy of a string into memory allocated with getroom().
207 + * Returns NULL when out of memory.
210 getroom_save(spin, s)
216 * Allocate the root of a word tree.
217 + * Returns NULL when out of memory.
225 * Get a wordnode_T, either from the list of previously freed nodes or
226 * allocate a new one.
227 + * Returns NULL when out of memory.
233 --spin->si_free_count;
235 #ifdef SPELL_PRINTTREE
236 ! n->wn_nr = ++spin->si_wordnode_nr;
241 --spin->si_free_count;
243 #ifdef SPELL_PRINTTREE
245 ! n->wn_nr = ++spin->si_wordnode_nr;
249 *** ../vim-7.3.108/src/version.c 2011-02-01 13:48:47.000000000 +0100
250 --- src/version.c 2011-02-01 13:56:38.000000000 +0100
254 { /* Add new patch number below this line */
260 hundred-and-one symptoms of being an internet addict:
261 174. You know what a listserv is.
263 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
264 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
265 \\\ an exciting new programming language -- http://www.Zimbu.org ///
266 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///