Avoid accessing freed memory and freeing already freed resources
Seen in smoketest in 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
This commit is contained in:
@@ -70,6 +70,8 @@ public:
|
|||||||
// checks if the menuhandle was created by VCL
|
// checks if the menuhandle was created by VCL
|
||||||
bool IsKnownMenuHandle( HMENU hMenu );
|
bool IsKnownMenuHandle( HMENU hMenu );
|
||||||
|
|
||||||
|
bool mbResourcesAlreadyFreed;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HINSTANCE mhInst; // default instance handle
|
HINSTANCE mhInst; // default instance handle
|
||||||
HINSTANCE mhPrevInst; // previous instance handle
|
HINSTANCE mhPrevInst; // previous instance handle
|
||||||
|
@@ -113,6 +113,8 @@ void ImplInitSalGDI()
|
|||||||
{
|
{
|
||||||
SalData* pSalData = GetSalData();
|
SalData* pSalData = GetSalData();
|
||||||
|
|
||||||
|
pSalData->mbResourcesAlreadyFreed = false;
|
||||||
|
|
||||||
// init stock brushes
|
// init stock brushes
|
||||||
pSalData->maStockPenColorAry[0] = PALETTERGB( 0, 0, 0 );
|
pSalData->maStockPenColorAry[0] = PALETTERGB( 0, 0, 0 );
|
||||||
pSalData->maStockPenColorAry[1] = PALETTERGB( 0xFF, 0xFF, 0xFF );
|
pSalData->maStockPenColorAry[1] = PALETTERGB( 0xFF, 0xFF, 0xFF );
|
||||||
@@ -290,6 +292,9 @@ void ImplFreeSalGDI()
|
|||||||
{
|
{
|
||||||
SalData* pSalData = GetSalData();
|
SalData* pSalData = GetSalData();
|
||||||
|
|
||||||
|
if (pSalData->mbResourcesAlreadyFreed)
|
||||||
|
return;
|
||||||
|
|
||||||
// destroy stock objects
|
// destroy stock objects
|
||||||
int i;
|
int i;
|
||||||
for ( i = 0; i < pSalData->mnStockPenCount; i++ )
|
for ( i = 0; i < pSalData->mnStockPenCount; i++ )
|
||||||
@@ -356,6 +361,8 @@ void ImplFreeSalGDI()
|
|||||||
|
|
||||||
// delete temporary font list
|
// delete temporary font list
|
||||||
ImplReleaseTempFonts( *pSalData );
|
ImplReleaseTempFonts( *pSalData );
|
||||||
|
|
||||||
|
pSalData->mbResourcesAlreadyFreed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ImplIsPaletteEntry( BYTE nRed, BYTE nGreen, BYTE nBlue )
|
static int ImplIsPaletteEntry( BYTE nRed, BYTE nGreen, BYTE nBlue )
|
||||||
|
Reference in New Issue
Block a user