Fix issue reported by Coverity Scan

CID: 1375395 (Dereference after null check)

Signed-off-by: Noah Metzger <noah.metzger@bib.uni-mannheim.de>
This commit is contained in:
Noah Metzger 2018-07-31 10:43:39 +02:00
parent 83a4eb3b44
commit d4490af06d

View File

@ -512,8 +512,10 @@ void RecodeBeamSearch::ContinueContext(const RecodeNode* prev, int index,
(previous->duplicate || previous->code == null_char_)) { (previous->duplicate || previous->code == null_char_)) {
previous = previous->prev; previous = previous->prev;
} }
prefix.Set(p, previous->code); if (previous != nullptr) {
full_code.Set(p, previous->code); prefix.Set(p, previous->code);
full_code.Set(p, previous->code);
}
} }
if (prev != nullptr && !is_simple_text_) { if (prev != nullptr && !is_simple_text_) {
if (top_n_flags_[prev->code] == top_n_flag) { if (top_n_flags_[prev->code] == top_n_flag) {