[Libreoffice-commits] .: 2 commits - i18npool/inc i18npool/source vcl/source
Caolán McNamara
caolan at kemper.freedesktop.org
Thu Apr 19 13:36:16 PDT 2012
i18npool/inc/transliterationImpl.hxx | 9 -----
i18npool/source/transliteration/transliterationImpl.cxx | 17 ++++++++--
vcl/source/gdi/pngread.cxx | 27 +++++++++++-----
3 files changed, 33 insertions(+), 20 deletions(-)
New commits:
commit 791687613a66c13ee9f5f12b9859bc4ed0eff67e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Apr 19 21:16:25 2012 +0100
remove static objects from static_initialization_and_destruction chain
diff --git a/i18npool/inc/transliterationImpl.hxx b/i18npool/inc/transliterationImpl.hxx
index 94fba96..cb06d0e 100644
--- a/i18npool/inc/transliterationImpl.hxx
+++ b/i18npool/inc/transliterationImpl.hxx
@@ -126,15 +126,6 @@ private:
com::sun::star::uno::Reference< XLocaleData > localedata;
com::sun::star::uno::Reference< com::sun::star::i18n::XExtendedTransliteration > caseignore;
- /** structure to cache the last transliteration body used. */
- struct TransBody
- {
- ::osl::Mutex mutex;
- ::rtl::OUString Name;
- ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XExtendedTransliteration > Body;
- };
- static TransBody lastTransBody;
-
virtual sal_Bool SAL_CALL loadModuleByName( const rtl::OUString& implName,
com::sun::star::uno::Reference<com::sun::star::i18n::XExtendedTransliteration> & body, const com::sun::star::lang::Locale& rLocale)
throw(com::sun::star::uno::RuntimeException);
diff --git a/i18npool/source/transliteration/transliterationImpl.cxx b/i18npool/source/transliteration/transliterationImpl.cxx
index 5e9f621..009f6e3 100644
--- a/i18npool/source/transliteration/transliterationImpl.cxx
+++ b/i18npool/source/transliteration/transliterationImpl.cxx
@@ -34,6 +34,7 @@
#include <com/sun/star/lang/XComponent.hpp>
#include <comphelper/processfactory.hxx>
+#include <rtl/instance.hxx>
#include <rtl/string.h>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
@@ -143,8 +144,6 @@ static struct TMlist {
{(TransliterationModules)0, (TransliterationModulesNew)0, NULL}
};
-TransliterationImpl::TransBody TransliterationImpl::lastTransBody;
-
// Constructor/Destructor
TransliterationImpl::TransliterationImpl(const Reference <XMultiServiceFactory>& xMSF) : xSMgr(xMSF)
{
@@ -587,11 +586,23 @@ TransliterationImpl::clear()
caseignoreOnly = sal_True;
}
+namespace
+{
+ /** structure to cache the last transliteration body used. */
+ struct TransBody
+ {
+ ::rtl::OUString Name;
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XExtendedTransliteration > Body;
+ };
+ class theTransBodyMutex : public rtl::Static<osl::Mutex, theTransBodyMutex> {};
+}
+
void TransliterationImpl::loadBody( OUString &implName, Reference<XExtendedTransliteration>& body )
throw (RuntimeException)
{
assert(!implName.isEmpty());
- ::osl::MutexGuard guard(lastTransBody.mutex);
+ ::osl::MutexGuard guard(theTransBodyMutex::get());
+ static TransBody lastTransBody;
if (implName != lastTransBody.Name)
{
lastTransBody.Body.set(
commit 88e0fa4aa3bea9ffeee372b6a428ca62cee41203
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Apr 19 20:46:59 2012 +0100
fail earlier on oversized images
diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index d279c01..81b9280 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -613,14 +613,6 @@ sal_Bool PNGReaderImpl::ImplReadHeader( const Size& rPreviewSizeHint )
mnScansize = static_cast< sal_uInt32 >( nScansize64 );
- // TODO: switch between both scanlines instead of copying
- mpInflateInBuf = new (std::nothrow) sal_uInt8[ mnScansize ];
- mpScanCurrent = mpInflateInBuf;
- mpScanPrior = new (std::nothrow) sal_uInt8[ mnScansize ];
-
- if ( !mpInflateInBuf || !mpScanPrior )
- return sal_False;
-
// calculate target size from original size and the preview hint
if( rPreviewSizeHint.Width() || rPreviewSizeHint.Height() )
{
@@ -655,6 +647,25 @@ sal_Bool PNGReaderImpl::ImplReadHeader( const Size& rPreviewSizeHint )
maTargetSize.Width() = (maOrigSize.Width() + mnPreviewMask) >> mnPreviewShift;
maTargetSize.Height() = (maOrigSize.Height() + mnPreviewMask) >> mnPreviewShift;
+ //round bits up to nearest multiple of 8 and divide by 8 to get num of bytes per pixel
+ int nBytesPerPixel = ((mnTargetDepth + 7) & ~7)/8;
+
+ //stupidly big, forget about it
+ if (maTargetSize.Width() >= SAL_MAX_INT32 / nBytesPerPixel / maTargetSize.Height())
+ {
+ SAL_WARN( "vcl", "overlarge png dimensions: " <<
+ maTargetSize.Width() << " x " << maTargetSize.Height() << " depth: " << mnTargetDepth);
+ return sal_False;
+ }
+
+ // TODO: switch between both scanlines instead of copying
+ mpInflateInBuf = new (std::nothrow) sal_uInt8[ mnScansize ];
+ mpScanCurrent = mpInflateInBuf;
+ mpScanPrior = new (std::nothrow) sal_uInt8[ mnScansize ];
+
+ if ( !mpInflateInBuf || !mpScanPrior )
+ return sal_False;
+
mpBmp = new Bitmap( maTargetSize, mnTargetDepth );
mpAcc = mpBmp->AcquireWriteAccess();
if( !mpAcc )
More information about the Libreoffice-commits
mailing list