diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2013-08-01 17:26:54 +0400 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2013-08-01 17:26:54 +0400 |
commit | ea67f29b8f99df18357a2a127389de6486c8594e (patch) | |
tree | 968dba78a1a3665606e795f405036267c546b56d | |
parent | 0bef0f63bf180a04bdf5c8f765aa1a5d4dbf53fa (diff) |
segfault outputting placeholder
-rw-r--r-- | moses-cmd/IOWrapper.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/moses-cmd/IOWrapper.cpp b/moses-cmd/IOWrapper.cpp index 177a13403..716274256 100644 --- a/moses-cmd/IOWrapper.cpp +++ b/moses-cmd/IOWrapper.cpp @@ -203,15 +203,16 @@ void OutputSurface(std::ostream &out, const Hypothesis &edge, const std::vector< size_t size = phrase.GetSize(); for (size_t pos = 0 ; pos < size ; pos++) { - const Factor *factor; + const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[0]); - if (placeholderFactor == NOT_FOUND) { - factor = phrase.GetFactor(pos, outputFactorOrder[0]); - } else { - factor = phrase.GetFactor(pos, placeholderFactor); + if (placeholderFactor != NOT_FOUND) { + const Factor *origFactor = phrase.GetFactor(pos, placeholderFactor); + if (origFactor) { + factor = origFactor; + } } - out << *factor; CHECK(factor); + out << *factor; for (size_t i = 1 ; i < outputFactorOrder.size() ; i++) { const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[i]); |