office-gobmx/sdext/source
Stephan Bergmann 12362fc496 LineParser::readNextToken gets called with m_nCharIndex==npos after all
eca89ece45 "Replace rtl_string_getTokenView with
o3tl::getToken" had erroneously assumed (from a succeeding `make check`) that
the only problematic call to o3tl::getToken with position==npos would be the one
in LineParser::readPath (and which had been addressed in that commit).

But e.g. loading ooo29794-4.pdf from the crash test corpus would also run into
that situation via LineParser::readNextToken,

> warn:legacy.osl:3090875:3090875:sdext/source/pdfimport/wrapper/wrapper.cxx:259: insufficient input
> soffice.bin: include/o3tl/string_view.hxx:34: std::string_view o3tl::getToken(std::string_view, char, std::size_t &): Assertion `position <= sv.size()' failed.

> #3  0x00007ffff7a67a16 in __GI___assert_fail (assertion=0x7fffb39ea58c "position <= sv.size()", file=0x7fffb39f2a7f "include/o3tl/string_view.hxx", line=34, function=0x7fffb39ef3a9 "std::string_view o3tl::getToken(std::string_view, char, std::size_t &)")
> #4  0x00007fffb3b60131 in o3tl::getToken(std::basic_string_view<char, std::char_traits<char> >, char, unsigned long&) (sv="eoClipPath", delimiter=32 ' ', position=@0x7fffffff29e0: 18446744073709551615) at include/o3tl/string_view.hxx:34
> #5  0x00007fffb3b5aa9f in pdfi::(anonymous namespace)::LineParser::readNextToken() (this=0x7fffffff29d0) at sdext/source/pdfimport/wrapper/wrapper.cxx:260
> #6  0x00007fffb3b5b2fa in pdfi::(anonymous namespace)::LineParser::readPath() (this=0x7fffffff29d0) at sdext/source/pdfimport/wrapper/wrapper.cxx:323
> #7  0x00007fffb3b59eb3 in pdfi::(anonymous namespace)::Parser::parseLine(rtl::OString const&) (this=0x7fffffff2d28, rLine="eoClipPath") at sdext/source/pdfimport/wrapper/wrapper.cxx:859
[...]

so better guard there.

Change-Id: Ibfd53fd9d3be0a3548d60cb26d59bb5966c5bc2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115916
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2021-05-21 14:50:14 +02:00
..
minimizer
pdfimport LineParser::readNextToken gets called with m_nCharIndex==npos after all 2021-05-21 14:50:14 +02:00
presenter