Fix memory leak on error return in wxOSX wxDisplay code.
Use wxScopedArray to ensure that memory is freed, even if wxCHECK_MSG() condition fails. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75956 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/display_impl.h"
|
#include "wx/display_impl.h"
|
||||||
|
#include "wx/scopedarray.h"
|
||||||
#include "wx/osx/private.h"
|
#include "wx/osx/private.h"
|
||||||
|
|
||||||
#if wxOSX_USE_COCOA_OR_CARBON
|
#if wxOSX_USE_COCOA_OR_CARBON
|
||||||
@@ -175,18 +176,14 @@ int wxDisplayFactoryMacOSX::GetFromPoint(const wxPoint& p)
|
|||||||
wxDisplayImpl *wxDisplayFactoryMacOSX::CreateDisplay(unsigned n)
|
wxDisplayImpl *wxDisplayFactoryMacOSX::CreateDisplay(unsigned n)
|
||||||
{
|
{
|
||||||
CGDisplayCount theCount = GetCount();
|
CGDisplayCount theCount = GetCount();
|
||||||
CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount];
|
wxScopedArray<CGDirectDisplayID> theIDs(theCount);
|
||||||
|
|
||||||
CGDisplayErr err = wxOSXGetDisplayList(theCount, theIDs, &theCount);
|
CGDisplayErr err = wxOSXGetDisplayList(theCount, theIDs, &theCount);
|
||||||
wxCHECK_MSG( err == CGDisplayNoErr, NULL, "wxOSXGetDisplayList() failed" );
|
wxCHECK_MSG( err == CGDisplayNoErr, NULL, "wxOSXGetDisplayList() failed" );
|
||||||
|
|
||||||
wxASSERT( n < theCount );
|
wxASSERT( n < theCount );
|
||||||
|
|
||||||
wxDisplayImplMacOSX *display = new wxDisplayImplMacOSX(n, theIDs[n]);
|
return new wxDisplayImplMacOSX(n, theIDs[n]);
|
||||||
|
|
||||||
delete [] theIDs;
|
|
||||||
|
|
||||||
return display;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
Reference in New Issue
Block a user