[Libreoffice-commits] core.git: 2 commits - sot/source tools/source vcl/source
Michael Stahl
mstahl at redhat.com
Mon Aug 31 07:38:59 PDT 2015
sot/source/sdstor/stgstrms.cxx | 15 ++++++++++++---
tools/source/stream/stream.cxx | 8 ++++++--
vcl/source/outdev/font.cxx | 2 +-
3 files changed, 19 insertions(+), 6 deletions(-)
New commits:
commit 1e9ecb2a2771ea6699e22b2693c96f4927d96ffb
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Aug 28 19:07:35 2015 +0200
vcl: try to disable font cache in CppUnit tests
With size 1 every ImplFontEntry should be immediately deleted, which
makes tools like valgrind and drmemory more useful.
Change-Id: Idec40c7cf7d927146f23830a42b3464c1675207f
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 6960525..ebe2bf9 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -1409,7 +1409,7 @@ void ImplFontCache::Acquire(ImplFontEntry* pEntry)
void ImplFontCache::Release(ImplFontEntry* pEntry)
{
- static const int FONTCACHE_MAX = 50;
+ static const int FONTCACHE_MAX = getenv("LO_TESTNAME") ? 1 : 50;
assert(pEntry->mnRefCount > 0 && "ImplFontCache::Release() - font refcount underflow");
if( --pEntry->mnRefCount > 0 )
commit 6a223b9acf8571e098cc6f74edcd3060d3fcfe27
Author: Michael Stahl <mstahl at redhat.com>
Date: Sat Aug 29 00:29:35 2015 +0200
sot: don't leak uninitialized memory into temp file
Both valgrind and drmemory complain about this in
SdExportTest::testSwappedOutImageExport() via
SfxOleThumbnailProperty::ImplSave().
Syscall param pwrite64(buf) points to uninitialised byte(s)
UNINITIALIZED READ: reading 0x0455b1b4-0x0455b1c8 20 byte(s) within...
It appears that the stream writes out everything up to the seek position
anyway (otherwise the size check wouldn't work, with sparse files)
so make sure it's all zeroed.
Also fix SvMemoryStream::ReAllocateMemory() to zero it.
Change-Id: Id86dfa65ef6f7d1bba4810f121e01473c5fcf4c7
diff --git a/sot/source/sdstor/stgstrms.cxx b/sot/source/sdstor/stgstrms.cxx
index ecd987f..c913beb 100644
--- a/sot/source/sdstor/stgstrms.cxx
+++ b/sot/source/sdstor/stgstrms.cxx
@@ -1188,9 +1188,9 @@ void StgTmpStrm::SetSize(sal_uInt64 n)
SvFileStream* s = new SvFileStream( aName, STREAM_READWRITE );
sal_uLong nCur = Tell();
sal_uLong i = nEndOfData;
+ std::unique_ptr<sal_uInt8[]> p(new sal_uInt8[ 4096 ]);
if( i )
{
- std::unique_ptr<sal_uInt8[]> p(new sal_uInt8[ 4096 ]);
Seek( 0L );
while( i )
{
@@ -1207,8 +1207,17 @@ void StgTmpStrm::SetSize(sal_uInt64 n)
// We have to write one byte at the end of the file
// if the file is bigger than the memstream to see
// if it fits on disk
- s->Seek( n - 1 );
- s->Write( &i, 1 );
+ s->Seek(nEndOfData);
+ memset(p.get(), 0x00, 4096);
+ i = n - nEndOfData;
+ while (i)
+ {
+ sal_uLong const nb = (i > 4096) ? 4096 : i;
+ if (s->Write(p.get(), nb) == nb)
+ i -= nb;
+ else
+ break; // error
+ }
s->Flush();
if( s->GetError() != SVSTREAM_OK )
i = 1;
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 88b320e..da91a21 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -1899,9 +1899,13 @@ bool SvMemoryStream::ReAllocateMemory( long nDiff )
if( nEndOfData >= nNewSize )
nEndOfData = nNewSize-1L;
}
- else if (nSize != 0)
+ else
{
- memcpy( pNewBuf, pBuf, (size_t)nSize );
+ if (nSize != 0)
+ {
+ memcpy( pNewBuf, pBuf, (size_t)nSize );
+ }
+ memset(pNewBuf + nSize, 0x00, nNewSize - nSize);
}
FreeMemory();
More information about the Libreoffice-commits
mailing list