[Libreoffice-commits] core.git: sdext/source
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Fri May 21 12:50:54 UTC 2021
sdext/source/pdfimport/wrapper/wrapper.cxx | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
New commits:
commit 12362fc496102b344dedef0a6ba130ba80b94149
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri May 21 13:38:32 2021 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri May 21 14:50:14 2021 +0200
LineParser::readNextToken gets called with m_nCharIndex==npos after all
eca89ece45ede76605a6102c94b3b67e1f8ff5aa "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 at redhat.com>
diff --git a/sdext/source/pdfimport/wrapper/wrapper.cxx b/sdext/source/pdfimport/wrapper/wrapper.cxx
index 78fb9cd0b331..2221f1ebe33f 100644
--- a/sdext/source/pdfimport/wrapper/wrapper.cxx
+++ b/sdext/source/pdfimport/wrapper/wrapper.cxx
@@ -256,7 +256,10 @@ OString lcl_unescapeLineFeeds(std::string_view i_rStr)
std::string_view LineParser::readNextToken()
{
- OSL_PRECOND(m_nCharIndex!=std::string_view::npos,"insufficient input");
+ if (m_nCharIndex == std::string_view::npos) {
+ SAL_WARN("sdext.pdfimport", "insufficient input");
+ return {};
+ }
return o3tl::getToken(m_aLine,' ',m_nCharIndex);
}
More information about the Libreoffice-commits
mailing list