Prevent text splitter bad array access and stl assertion crash (fedora rpmbuild) in marginal case. There were probably no real consequence beyond triggering the assertion

This commit is contained in:
Jean-Francois Dockes 2018-11-15 18:19:39 +01:00
parent 0f8775e42d
commit 55e2fe5d27

View File

@ -340,6 +340,15 @@ bool TextSplit::words_from_span(size_t bp)
cerr << endl;
#endif
int spanwords = int(m_words_in_span.size());
// It seems that something like: tv_combo-sample_util.Po@am_quote
// can get the splitter to call doemit with a span of '@' and
// words_in_span==0, which then causes a crash when accessing
// words_in_span[0] if the stl assertions are active (e.g. Fedora
// RPM build). Not too sure what the right fix would be, but for
// now, just defend against it
if (spanwords == 0) {
return true;
}
int pos = m_spanpos;
// Byte position of the span start
size_t spboffs = bp - m_span.size();