From 55e2fe5d27f328b7afb207a561ee618052fad9ac Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 15 Nov 2018 18:19:39 +0100 Subject: [PATCH] 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 --- src/common/textsplit.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/common/textsplit.cpp b/src/common/textsplit.cpp index c5b47d27..bd80f049 100644 --- a/src/common/textsplit.cpp +++ b/src/common/textsplit.cpp @@ -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();