compilerplugins/clang/badstatics.cxx | 57 +++++++++++++++++++++++++++++++++++ sal/osl/unx/file_url.cxx | 9 ++++- svx/source/form/filtnav.cxx | 30 +++--------------- vcl/workben/vcldemo.cxx | 2 - 4 files changed, 71 insertions(+), 27 deletions(-)
New commits: commit 3e7afe0037d6d165abbeb32d4e5fb68ac8a9aeea Author: Stephan Bergmann <[email protected]> Date: Mon Nov 2 16:37:29 2015 +0100 Clean up osl_getSystemPathFromFileURL handling of relative //... URLs (i.e., starting with an authority component); treating input starting with a single slash (i.e., starting with an absolute path component) as a relative URL instead of as an absolute pathname would cause e.g. CppunitTest_sal_osl_file to fail Change-Id: Ie340881974c5e9451ab7e0a9bfb21176b8f5666d diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx index 45e96e7..1d8c1fd 100644 --- a/sal/osl/unx/file_url.cxx +++ b/sal/osl/unx/file_url.cxx @@ -88,8 +88,13 @@ oslFileError SAL_CALL osl_getSystemPathFromFileURL( rtl_uString *ustrFileURL, rt sal_Unicode encodedSlash[3] = { '%', '2', 'F' }; - /* a valid file url may not start with '/' */ - if( ( 0 == ustrFileURL->length ) || ( '/' == ustrFileURL->buffer[0] ) ) + // For compatibility with assumptions in other parts of the code base, + // assume that anything starting with a slash is a system path instead of a + // (relative) file URL (except if it starts with two slashes, in which case + // it is a relative URL with an authority component): + if (ustrFileURL->length == 0 + || (ustrFileURL->buffer[0] == '/' + && (ustrFileURL->length == 1 || ustrFileURL->buffer[1] != '/'))) { return osl_File_E_INVAL; } commit bf18f1b3535dd17f9bf584cab15ee6a7fd431257 Author: Michael Stahl <[email protected]> Date: Fri Oct 30 16:05:42 2015 +0100 compilerplugins: add "badstatics" to detect abuse of VCL Bitmaps VCL Image/Bitmap/BitmapEx instances must not have static life-time because then they will be destructed after DeInitVCL() and that likely segfaults. Change-Id: I3ff8d32de729c971b190028094cb4efe206395e2 diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx new file mode 100644 index 0000000..136e1db --- /dev/null +++ b/compilerplugins/clang/badstatics.cxx @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "plugin.hxx" + +namespace { + +class BadStatics + : public clang::RecursiveASTVisitor<BadStatics> + , public loplugin::Plugin +{ + +public: + explicit BadStatics(InstantiationData const& rData) : Plugin(rData) {} + + void run() override { + if (compiler.getLangOpts().CPlusPlus) { // no non-trivial dtors in C + TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); + } + } + + bool VisitVarDecl(VarDecl const*const pVarDecl) + { + if (ignoreLocation(pVarDecl)) { + return true; + } + + if (pVarDecl->hasGlobalStorage()) { + auto const type(pVarDecl->getType().getUnqualifiedType().getCanonicalType().getAsString()); + if ( type == "class Image" + || type == "class Bitmap" + || type == "class BitmapEx" + ) + { + report(DiagnosticsEngine::Warning, + "bad static variable causes crash on shutdown", + pVarDecl->getLocation()) + << pVarDecl->getSourceRange(); + } + } + + return true; + } + +}; + +loplugin::Plugin::Registration<BadStatics> X("badstatics"); + +} // namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index 8bb80d3..f33c0d1 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -156,14 +156,8 @@ TYPEINIT1(FmFormItem, FmParentData); Image FmFormItem::GetImage() const { - static Image aImage; - - if (!aImage) - { - ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL ) ); - aImage = aNavigatorImages.GetImage( RID_SVXIMG_FORM ); - } - return aImage; + ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL ) ); + return aNavigatorImages.GetImage( RID_SVXIMG_FORM ); } @@ -187,14 +181,8 @@ FmFilterItem* FmFilterItems::Find( const ::sal_Int32 _nFilterComponentIndex ) co Image FmFilterItems::GetImage() const { - static Image aImage; - - if (!aImage) - { - ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL ) ); - aImage = aNavigatorImages.GetImage( RID_SVXIMG_FILTER ); - } - return aImage; + ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL ) ); + return aNavigatorImages.GetImage( RID_SVXIMG_FILTER ); } @@ -213,14 +201,8 @@ FmFilterItem::FmFilterItem( FmFilterItems* pParent, Image FmFilterItem::GetImage() const { - static Image aImage; - - if (!aImage) - { - ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL ) ); - aImage = aNavigatorImages.GetImage( RID_SVXIMG_FIELD ); - } - return aImage; + ImageList aNavigatorImages( SVX_RES( RID_SVXIMGLIST_FMEXPL ) ); + return aNavigatorImages.GetImage( RID_SVXIMG_FIELD ); } diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 03493cd..1e7c5cc 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -650,7 +650,7 @@ public: // be done with a shader / gradient static void SimulateBorderStretch(OutputDevice &rDev, const Rectangle& r) { - static BitmapEx aPageShadowMask("sw/res/page-shadow-mask.png"); + BitmapEx aPageShadowMask("sw/res/page-shadow-mask.png"); BitmapEx aRight(aPageShadowMask); sal_Int32 nSlice = (aPageShadowMask.GetSizePixel().Width() - 3) / 4; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
