[Libreoffice-commits] core.git: tools/source

Stephan Bergmann sbergman at redhat.com
Tue Feb 28 07:52:57 UTC 2017


 tools/source/stream/stream.cxx |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit d3b0b1512335c2ffbda04d6f06c8a53855c6072a
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Feb 28 08:51:13 2017 +0100

    Avoid -fsanitize=null
    
    ...during CppunitTest_xmlsecurity_pdfsigning:
    
    > tools/source/stream/stream.cxx:1220:20: runtime error: null pointer passed as argument 1, which is declared to never be null
    > /usr/include/string.h:43:28: note: nonnull attribute specified here
    >     #0 0x7fb2116abe4a in SvStream::ReadBytes(void*, unsigned long) tools/source/stream/stream.cxx:1220:13
    >     #1 0x7fb1dee7a4f0 in xmlsecurity::pdfio::PDFStreamElement::Read(SvStream&) xmlsecurity/source/pdfio/pdfdocument.cxx:3639:13
    >     #2 0x7fb1dee350ec in xmlsecurity::pdfio::PDFDocument::Tokenize(SvStream&, xmlsecurity::pdfio::TokenizeMode, std::__debug::vector<std::unique_ptr<xmlsecurity::pdfio::PDFElement, std::default_delete<xmlsecurity::pdfio::PDFElement> >, std::allocator<std::unique_ptr<xmlsecurity::pdfio::PDFElement, std::default_delete<xmlsecurity::pdfio::PDFElement> > > >&, xmlsecurity::pdfio::PDFObjectElement*) xmlsecurity/source/pdfio/pdfdocument.cxx:1153:44
    >     #3 0x7fb1dee464d3 in xmlsecurity::pdfio::PDFDocument::Read(SvStream&) xmlsecurity/source/pdfio/pdfdocument.cxx:1306:12
    >     #4 0x7fb1e7916ffe in PDFSigningTest::verify(rtl::OUString const&, unsigned long, rtl::OString const&) xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx:127:5
    >     #5 0x7fb1e791dd86 in PDFSigningTest::sign(rtl::OUString const&, rtl::OUString const&, unsigned long) xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx:178:5
    >     #6 0x7fb1e791ef8e in PDFSigningTest::testPDFAdd() xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx:189:29
    >     #7 0x7fb1e798885b in CppUnit::TestCaller<PDFSigningTest>::runTest() workdir/UnpackedTarball/cppunit/include/cppunit/TestCaller.h:166:6
    >     #8 0x7fb22b8bfd8b in CppUnit::TestCaseMethodFunctor::operator()() const workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:32:5
    >     #9 0x7fb211f6699f in (anonymous namespace)::Protector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) test/source/vclbootstrapprotector.cxx:36:14
    >     #10 0x7fb22b87e3ce in CppUnit::ProtectorChain::ProtectFunctor::operator()() const workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:20:25
    >     #11 0x7fb21ba510cf in (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) unotest/source/cpp/unobootstrapprotector/unobootstrapprotector.cxx:89:12
    >     #12 0x7fb22b87e3ce in CppUnit::ProtectorChain::ProtectFunctor::operator()() const workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:20:25
    >     #13 0x7fb21f6ff2c4 in (anonymous namespace)::Prot::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) unotest/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx:63:16
    >     #14 0x7fb22b87e3ce in CppUnit::ProtectorChain::ProtectFunctor::operator()() const workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:20:25
    >     #15 0x7fb22b7fc350 in CppUnit::DefaultProtector::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) workdir/UnpackedTarball/cppunit/src/cppunit/DefaultProtector.cpp:15:12
    >     #16 0x7fb22b87e3ce in CppUnit::ProtectorChain::ProtectFunctor::operator()() const workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:20:25
    >     #17 0x7fb22b87ae70 in CppUnit::ProtectorChain::protect(CppUnit::Functor const&, CppUnit::ProtectorContext const&) workdir/UnpackedTarball/cppunit/src/cppunit/ProtectorChain.cpp:77:18
    >     #18 0x7fb22b93a0f5 in CppUnit::TestResult::protect(CppUnit::Functor const&, CppUnit::Test*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:181:28
    >     #19 0x7fb22b8bdfa4 in CppUnit::TestCase::run(CppUnit::TestResult*) workdir/UnpackedTarball/cppunit/src/cppunit/TestCase.cpp:91:13
    >     #20 0x7fb22b8c27a7 in CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64:30
    >     #21 0x7fb22b8c1819 in CppUnit::TestComposite::run(CppUnit::TestResult*) workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:23:3
    >     #22 0x7fb22b8c27a7 in CppUnit::TestComposite::doRunChildTests(CppUnit::TestResult*) workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:64:30
    >     #23 0x7fb22b8c1819 in CppUnit::TestComposite::run(CppUnit::TestResult*) workdir/UnpackedTarball/cppunit/src/cppunit/TestComposite.cpp:23:3
    >     #24 0x7fb22b9785c9 in CppUnit::TestRunner::WrappingSuite::run(CppUnit::TestResult*) workdir/UnpackedTarball/cppunit/src/cppunit/TestRunner.cpp:47:27
    >     #25 0x7fb22b93840d in CppUnit::TestResult::runTest(CppUnit::Test*) workdir/UnpackedTarball/cppunit/src/cppunit/TestResult.cpp:148:9
    >     #26 0x7fb22b97989b in CppUnit::TestRunner::run(CppUnit::TestResult&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) workdir/UnpackedTarball/cppunit/src/cppunit/TestRunner.cpp:96:14
    >     #27 0x53043c in (anonymous namespace)::ProtectedFixtureFunctor::run() const sal/cppunittester/cppunittester.cxx:305:20
    >     #28 0x52c089 in sal_main() sal/cppunittester/cppunittester.cxx:455:20
    >     #29 0x52a742 in main sal/cppunittester/cppunittester.cxx:362:1
    >     #30 0x7fb229b05400 in __libc_start_main /usr/src/debug/glibc-2.24-33-ge9e69e4/csu/../csu/libc-start.c:289
    >     #31 0x437d49 in _start (workdir/LinkTarget/Executable/cppunittester+0x437d49)
    
    Change-Id: I8bf8c28219b4525874f83fbb164eb5eec02ac1b6

diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index f54924f..99a4d22 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1217,7 +1217,8 @@ std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount )
         if (nCount <= static_cast<std::size_t>(m_nBufActualLen - m_nBufActualPos))
         {
             // => yes
-            memcpy(pData, m_pBufPos, (size_t) nCount);
+            if (nCount != 0)
+                memcpy(pData, m_pBufPos, (size_t) nCount);
             m_nBufActualPos = m_nBufActualPos + (sal_uInt16)nCount;
             m_pBufPos += nCount;
             m_nBufFree = m_nBufFree - (sal_uInt16)nCount;


More information about the Libreoffice-commits mailing list