[Libreoffice-commits] .: 4 commits - svl/source tools/source vcl/source vcl/unx
David Tardon
dtardon at kemper.freedesktop.org
Wed May 18 06:00:14 PDT 2011
svl/source/items/itemset.cxx | 4 ++--
tools/source/rc/resmgr.cxx | 10 +++++-----
vcl/source/fontsubset/ttcr.cxx | 21 ++++++++++++---------
vcl/unx/source/printer/jobdata.cxx | 2 ++
4 files changed, 21 insertions(+), 16 deletions(-)
New commits:
commit ac4ac256848fae6c7428050df906f3733055a45b
Author: David Tardon <dtardon at redhat.com>
Date: Wed May 18 14:40:26 2011 +0200
make static to avoid use of dead object in ~ResMgr
diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx
index 394e0d2..9c12821 100644
--- a/tools/source/rc/resmgr.cxx
+++ b/tools/source/rc/resmgr.cxx
@@ -120,7 +120,7 @@ class InternalResMgr
void * LoadGlobalRes( RESOURCE_TYPE nRT, sal_uInt32 nId,
void **pResHandle );
public:
- void FreeGlobalRes( void *, void * );
+ static void FreeGlobalRes( void *, void * );
SvStream * GetBitmapStream( sal_uInt32 nResId );
};
@@ -962,7 +962,7 @@ void ResMgr::Init( const OUString& rFileName )
pVoid = pImpRes->LoadGlobalRes( RSC_VERSIONCONTROL, RSCVERSION_ID,
&aResHandle );
if ( pVoid )
- pImpRes->FreeGlobalRes( aResHandle, pVoid );
+ InternalResMgr::FreeGlobalRes( aResHandle, pVoid );
else
{
ByteString aStr( "Wrong version:\n" );
@@ -997,7 +997,7 @@ ResMgr::~ResMgr()
while( nCurStack > 0 )
{
if( ( aStack[nCurStack].Flags & (RC_GLOBAL | RC_NOTFOUND) ) == RC_GLOBAL )
- pImpRes->FreeGlobalRes( aStack[nCurStack].aResHandle,
+ InternalResMgr::FreeGlobalRes( aStack[nCurStack].aResHandle,
aStack[nCurStack].pResource );
nCurStack--;
}
@@ -1284,7 +1284,7 @@ void ResMgr::PopContext( const Resource* pResObj )
// Resource freigeben
if( (pTop->Flags & (RC_GLOBAL | RC_NOTFOUND)) == RC_GLOBAL )
// kann auch Fremd-Ressource sein
- pImpRes->FreeGlobalRes( pTop->aResHandle, pTop->pResource );
+ InternalResMgr::FreeGlobalRes( pTop->aResHandle, pTop->pResource );
decStack();
}
}
@@ -2027,7 +2027,7 @@ UniString SimpleResMgr::ReadString( sal_uInt32 nId )
// not neccessary with te current implementation which holds the string table permanently, but to be sure ....
// note: pFallback cannot be NULL here and is either the fallback or m_pResImpl
- pFallback->FreeGlobalRes( pResHeader, pResHandle );
+ InternalResMgr::FreeGlobalRes( pResHeader, pResHandle );
if( m_pResImpl != pFallback )
{
osl::Guard<osl::Mutex> aGuard2( getResMgrMutex() );
commit 434f39d84692afb8d2da47c8ca7c27294c828623
Author: David Tardon <dtardon at redhat.com>
Date: Wed May 18 14:19:11 2011 +0200
one * is sufficient here :)
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 47921f2..3be762d 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -1876,12 +1876,12 @@ static SfxItemArray AddItem_Impl(SfxItemArray pItems, sal_uInt16 nOldSize, sal_u
{
// alte Items vor nPos kopieren
if ( nPos )
- memcpy( (void*) pNew, pItems, nPos * sizeof(SfxPoolItem **) );
+ memcpy( (void*) pNew, pItems, nPos * sizeof(SfxPoolItem *) );
// alte Items hinter nPos kopieren
if ( nPos < nOldSize )
memcpy( (void*) (pNew + nPos + 1), pItems + nPos,
- (nOldSize-nPos) * sizeof(SfxPoolItem **) );
+ (nOldSize-nPos) * sizeof(SfxPoolItem *) );
}
// neues Item initialisieren
commit 801d016474b673767a60ff86ee8255081fda7388
Author: David Tardon <dtardon at redhat.com>
Date: Wed May 18 09:56:40 2011 +0200
delete[] after use
diff --git a/vcl/unx/source/printer/jobdata.cxx b/vcl/unx/source/printer/jobdata.cxx
index 28b048e..a74a255 100644
--- a/vcl/unx/source/printer/jobdata.cxx
+++ b/vcl/unx/source/printer/jobdata.cxx
@@ -168,9 +168,11 @@ bool JobData::getStreamBuffer( void*& pData, int& bytes )
// now append the PPDContext stream buffer
aStream.WriteLine( "PPDContexData" );
sal_uLong nBytes;
+ // getStreamableBuffer allocates the buffer using new[]
void* pContextBuffer = m_aContext.getStreamableBuffer( nBytes );
if( nBytes )
aStream.Write( pContextBuffer, nBytes );
+ delete[] reinterpret_cast<char*>(pContextBuffer);
// success
pData = rtl_allocateMemory( bytes = aStream.Tell() );
commit 90225a18000e2620cd69162fc0a226d7de8bdeee
Author: David Tardon <dtardon at redhat.com>
Date: Wed May 18 09:37:54 2011 +0200
avoid memory leak
diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx
index 8235c3a..8834465 100644
--- a/vcl/source/fontsubset/ttcr.cxx
+++ b/vcl/source/fontsubset/ttcr.cxx
@@ -399,16 +399,19 @@ int StreamToFile(TrueTypeCreator *_this, const char* fname)
FILE* fd;
if ((r = StreamToMemory(_this, &ptr, &length)) != SF_OK) return r;
- if (!fname) return SF_BADFILE;
- if ((fd = fopen(fname, "wb")) == NULL) return SF_BADFILE;
-
- if (fwrite(ptr, 1, length, fd) != length) {
- r = SF_FILEIO;
- } else {
- r = SF_OK;
+ if (fname && (fd = fopen(fname, "wb")) != NULL)
+ {
+ if (fwrite(ptr, 1, length, fd) != length) {
+ r = SF_FILEIO;
+ } else {
+ r = SF_OK;
+ }
+ fclose(fd);
+ }
+ else
+ {
+ r = SF_BADFILE;
}
-
- fclose(fd);
free(ptr);
return r;
}
More information about the Libreoffice-commits
mailing list