summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2014-06-03 23:36:18 +0300
committerMichael Meeks <michael.meeks@collabora.com>2014-06-10 16:37:11 +0100
commit4e4d17fb5cc06387554c69d075fc063bedfb55d8 (patch)
treed629e032f6efe6ee7e6ac3d66ad0f9ed3523ab28 /vcl
parent276fb5136d142887e981aa6858735a47af9d7bf5 (diff)
Avoid accessing freed memory and freeing already freed resources
Seen in smoketest a 4.2-based branch, but might perhaps happen in master too. Should not hurt in any case to be more careful. ImplFreeSalGDI() is called both from SalAbort() and from DestroySalInstance(). Change-Id: Ifac37e8ecfb432848bd3451dbda8634c59a06fba
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/win/saldata.hxx2
-rw-r--r--vcl/win/source/gdi/salgdi.cxx7
2 files changed, 9 insertions, 0 deletions
diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index d1464d5958ee..1d54637ffce2 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -70,6 +70,8 @@ public:
// checks if the menuhandle was created by VCL
sal_Bool IsKnownMenuHandle( HMENU hMenu );
+ bool mbResourcesAlreadyFreed;
+
public:
HINSTANCE mhInst; // default instance handle
HINSTANCE mhPrevInst; // previous instance handle
diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx
index e3a660f3f7b1..5d1cd357a186 100644
--- a/vcl/win/source/gdi/salgdi.cxx
+++ b/vcl/win/source/gdi/salgdi.cxx
@@ -136,6 +136,8 @@ void ImplInitSalGDI()
{
SalData* pSalData = GetSalData();
+ pSalData->mbResourcesAlreadyFreed = false;
+
// init stock brushes
pSalData->maStockPenColorAry[0] = PALETTERGB( 0, 0, 0 );
pSalData->maStockPenColorAry[1] = PALETTERGB( 0xFF, 0xFF, 0xFF );
@@ -315,6 +317,9 @@ void ImplFreeSalGDI()
{
SalData* pSalData = GetSalData();
+ if (pSalData->mbResourcesAlreadyFreed)
+ return;
+
// destroy stock objects
int i;
for ( i = 0; i < pSalData->mnStockPenCount; i++ )
@@ -381,6 +386,8 @@ void ImplFreeSalGDI()
// delete temporary font list
ImplReleaseTempFonts( *pSalData );
+
+ pSalData->mbResourcesAlreadyFreed = true;
}
// -----------------------------------------------------------------------