From af013c17d7c156c8219b4c4c1568e4108ad09ba1 Mon Sep 17 00:00:00 2001 From: graehl Date: Fri, 23 Jul 2010 19:30:01 +0000 Subject: fixed (NULL-1 < 0) segfault for fsa stateful feature with empty eos string git-svn-id: https://ws10smt.googlecode.com/svn/trunk@385 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/ff_fsa.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/decoder/ff_fsa.h b/decoder/ff_fsa.h index e359cfd9..4e40f51b 100755 --- a/decoder/ff_fsa.h +++ b/decoder/ff_fsa.h @@ -102,20 +102,19 @@ template void *FsaScan(FsaFF const& ff,SentenceMetadata const& smeta,WordID const* i, WordID const* end,FeatureVector *features, void *cs,void *ns) { // extra code - IT'S FOR EFFICIENCY, MAN! IT'S OK! definitely no bugs here. void *os,*es; - WordID const* e=end-1; // boundcheck 1 earlier because in loop below we use i+1 before rechecking if ((end-i)&1) { // odd # of words os=cs; es=ns; - i-=1; goto odd; } else { + i+=1; es=cs; os=ns; } - for (;io + for (;io odd: - ff.Scan(smeta,*(i+1),os,es,features); // o->e + ff.Scan(smeta,i[0],os,es,features); // o->e } return es; } @@ -194,8 +193,9 @@ template struct FsaTypedScan : public FsaTypedBase { void Scan(SentenceMetadata const& smeta,WordID w,void const* st,void *next_state,FeatureVector *features) const { Impl const* impl=static_cast(this); + FSADBG("Scan "<<(*features)[impl->fid_]<<" = "<state(st)<<" ->"<ScanTyped(smeta,w,impl->state(st),impl->state(next_state),features); - FSADBG("Scan "<state(st)<<" ->"<state(next_state)<<" = "<<(*features)[impl->fid_]<state(next_state)<<" = "<<(*features)[impl->fid_]<