summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2013-06-30 13:17:24 +0200
committerBram Moolenaar <Bram@vim.org>2013-06-30 13:17:24 +0200
commit55480dccf4591859789b15a6c49162b7c2a476e0 (patch)
treeaf9f67c1ed4106288d7898621a6fd159082dbb5a
parenta4c8dcbdae63b8fba688db87d9cdf391ae883e62 (diff)
downloadvim-git-55480dccf4591859789b15a6c49162b7c2a476e0.tar.gz
updated for version 7.3.1272v7.3.1272
Problem: Crash when editing Ruby file. (Aliaksandr Rahalevich) Solution: Reallocate the state list when necessary.
-rw-r--r--src/regexp_nfa.c41
-rw-r--r--src/version.c2
2 files changed, 35 insertions, 8 deletions
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index bd3818d71..5f000f6a0 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -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;
diff --git a/src/version.c b/src/version.c
index 3a0b36738..249032366 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1272,
+/**/
1271,
/**/
1270,