From 03989754cb2511431e1df6001fca41b3806ad461 Mon Sep 17 00:00:00 2001 From: Wilker Aziz Date: Thu, 19 Feb 2015 08:52:16 +0000 Subject: when ApplyRules resizes nodes_, the reference to `cat` may become invalid and the parser segfaults (observed with grammars full of unary rules) --- decoder/bottom_up_parser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decoder/bottom_up_parser.cc b/decoder/bottom_up_parser.cc index a614b8b3..7ce8e09d 100644 --- a/decoder/bottom_up_parser.cc +++ b/decoder/bottom_up_parser.cc @@ -274,7 +274,7 @@ void PassiveChart::ApplyRules(const int i, void PassiveChart::ApplyUnaryRules(const int i, const int j) { const vector& nodes = chart_(i,j); // reference is important! for (unsigned di = 0; di < nodes.size(); ++di) { - const WordID& cat = forest_->nodes_[nodes[di]].cat_; + const WordID cat = forest_->nodes_[nodes[di]].cat_; for (unsigned ri = 0; ri < unaries_.size(); ++ri) { //cerr << "At (" << i << "," << j << "): applying " << unaries_[ri]->AsString() << endl; if (unaries_[ri]->f()[0] == cat) { -- cgit v1.2.3