diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-06-09 00:02:50 -0300 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-06-30 03:57:50 -0400 |
commit | be3a4b6ca81c4e9dd3faa81dc01f53468ceed3ad (patch) | |
tree | 60615f7476a791a1e57deaafa414585bd802898f /src/nvim/regexp.c | |
parent | d723e7fd61d48b037a2b8360162efa1cddad64d2 (diff) | |
download | rneovim-be3a4b6ca81c4e9dd3faa81dc01f53468ceed3ad.tar.gz rneovim-be3a4b6ca81c4e9dd3faa81dc01f53468ceed3ad.tar.bz2 rneovim-be3a4b6ca81c4e9dd3faa81dc01f53468ceed3ad.zip |
ga_growsize should be >= 1
I know it could be 0 sometimes. Running the tests with
`assert(gap->ga_growsize > 0)` in ga_grow() crashes nvim while running the
tests.
- Add a setter for ga_growsize that checks whether the value passed is >=1 (log
in case it's not)
- log when ga_grow() tries to use a ga_growsize that's not >=1
- use GA_EMPTY_INIT_VALUE is many places
Diffstat (limited to 'src/nvim/regexp.c')
-rw-r--r-- | src/nvim/regexp.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index ea61436e05..29f090c6b7 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -3180,8 +3180,8 @@ static int reg_line_lbr; /* "\n" in string is line break */ * or regbehind_T. * "backpos_T" is a table with backpos_T for BACK */ -static garray_T regstack = {0, 0, 0, 0, NULL}; -static garray_T backpos = {0, 0, 0, 0, NULL}; +static garray_T regstack = GA_EMPTY_INIT_VALUE; +static garray_T backpos = GA_EMPTY_INIT_VALUE; /* * Both for regstack and backpos tables we use the following strategy of @@ -3319,13 +3319,13 @@ static long bt_regexec_both(char_u *line, * onto the regstack. */ ga_init(®stack, 1, REGSTACK_INITIAL); ga_grow(®stack, REGSTACK_INITIAL); - regstack.ga_growsize = REGSTACK_INITIAL * 8; + ga_set_growsize(®stack, REGSTACK_INITIAL * 8); } if (backpos.ga_data == NULL) { ga_init(&backpos, sizeof(backpos_T), BACKPOS_INITIAL); ga_grow(&backpos, BACKPOS_INITIAL); - backpos.ga_growsize = BACKPOS_INITIAL * 8; + ga_set_growsize(&backpos, BACKPOS_INITIAL * 8); } if (REG_MULTI) { |