From 0665c39c36c3026887a8984f96e4483d6918a98e Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Tue, 5 Mar 2019 22:35:23 +0000 Subject: [PATCH] Do not access vector element by reference that is invalidated due to reallocation. --- re2c/src/dfa/closure_posix.h | 4 ++-- re2c/src/dfa/determinization.cc | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/re2c/src/dfa/closure_posix.h b/re2c/src/dfa/closure_posix.h index b598d176..d767f30c 100644 --- a/re2c/src/dfa/closure_posix.h +++ b/re2c/src/dfa/closure_posix.h @@ -145,7 +145,7 @@ bool scan(ctx_t &ctx, nfa_state_t *q, bool all) bool any = false; typedef typename ctx_t::conf_t conf_t; - const conf_t &x = ctx.state[q->clos]; + const conf_t x = ctx.state[q->clos]; switch (q->type) { case nfa_state_t::NIL: @@ -253,7 +253,7 @@ void closure_posix_gtop(ctx_t &ctx) DINCCOUNT_CLSCANS(ctx); typedef typename ctx_t::conf_t conf_t; - const conf_t &x = ctx.state[q->clos]; + const conf_t x = ctx.state[q->clos]; switch (q->type) { case nfa_state_t::NIL: diff --git a/re2c/src/dfa/determinization.cc b/re2c/src/dfa/determinization.cc index 879db8c3..2b9e919f 100644 --- a/re2c/src/dfa/determinization.cc +++ b/re2c/src/dfa/determinization.cc @@ -278,6 +278,9 @@ determ_context_t::determ_context_t(const opt_t *opts, Msg &msg const size_t ncores = nfa.ncores; const size_t ntags = nfa.tags.size(); + reach.reserve(nstates); + state.reserve(nstates); + dc_hc_caches.resize(ntags); dc_path1.reserve(ntags); dc_path2.reserve(ntags); -- 2.40.0