]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.1272 v7.3.1272
authorBram Moolenaar <Bram@vim.org>
Sun, 30 Jun 2013 11:17:24 +0000 (13:17 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 30 Jun 2013 11:17:24 +0000 (13:17 +0200)
Problem:    Crash when editing Ruby file. (Aliaksandr Rahalevich)
Solution:   Reallocate the state list when necessary.

src/regexp_nfa.c
src/version.c

index bd3818d71e8e89b61af2ec620b1b76da2e361087..5f000f6a096eeb33adf61cc5607a93e2490aa481 100644 (file)
@@ -4228,14 +4228,39 @@ addstate_here(l, state, subs, pim, ip)
     }
     else if (count > 1)
     {
-       /* make space for new states, then move them from the
-        * end to the current position */
-       mch_memmove(&(l->t[listidx + count]),
-               &(l->t[listidx + 1]),
-               sizeof(nfa_thread_T) * (l->n - listidx - 1));
-       mch_memmove(&(l->t[listidx]),
-               &(l->t[l->n - 1]),
-               sizeof(nfa_thread_T) * count);
+       if (l->n + count - 1 >= l->len)
+       {
+           /* not enough space to move the new states, reallocate the list
+            * and move the states to the right position */
+           nfa_thread_T *newl;
+
+           l->len = l->len * 3 / 2 + 50;
+           newl = (nfa_thread_T *)alloc(l->len * sizeof(nfa_thread_T));
+           if (newl == NULL)
+               return;
+           mch_memmove(&(newl[0]),
+                   &(l->t[0]),
+                   sizeof(nfa_thread_T) * listidx);
+           mch_memmove(&(newl[listidx]),
+                   &(l->t[l->n - count]),
+                   sizeof(nfa_thread_T) * count);
+           mch_memmove(&(newl[listidx + count]),
+                   &(l->t[listidx + 1]),
+                   sizeof(nfa_thread_T) * (l->n - count - listidx - 1));
+           vim_free(l->t);
+           l->t = newl;
+       }
+       else
+       {
+           /* make space for new states, then move them from the
+            * end to the current position */
+           mch_memmove(&(l->t[listidx + count]),
+                   &(l->t[listidx + 1]),
+                   sizeof(nfa_thread_T) * (l->n - listidx - 1));
+           mch_memmove(&(l->t[listidx]),
+                   &(l->t[l->n - 1]),
+                   sizeof(nfa_thread_T) * count);
+       }
     }
     --l->n;
     *ip = listidx - 1;
index 3a0b3673876132b0374b2a1de8f0c5c99aa50d4a..24903236605fccdbbad0f2759f2065d0e8e5fb72 100644 (file)
@@ -728,6 +728,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1272,
 /**/
     1271,
 /**/