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:
parent
3dd1d4d915
commit
563f41c686
@ -34,6 +34,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/display_impl.h"
|
||||
#include "wx/scopedarray.h"
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
#if wxOSX_USE_COCOA_OR_CARBON
|
||||
@ -175,18 +176,14 @@ int wxDisplayFactoryMacOSX::GetFromPoint(const wxPoint& p)
|
||||
wxDisplayImpl *wxDisplayFactoryMacOSX::CreateDisplay(unsigned n)
|
||||
{
|
||||
CGDisplayCount theCount = GetCount();
|
||||
CGDirectDisplayID* theIDs = new CGDirectDisplayID[theCount];
|
||||
wxScopedArray<CGDirectDisplayID> theIDs(theCount);
|
||||
|
||||
CGDisplayErr err = wxOSXGetDisplayList(theCount, theIDs, &theCount);
|
||||
wxCHECK_MSG( err == CGDisplayNoErr, NULL, "wxOSXGetDisplayList() failed" );
|
||||
|
||||
wxASSERT( n < theCount );
|
||||
|
||||
wxDisplayImplMacOSX *display = new wxDisplayImplMacOSX(n, theIDs[n]);
|
||||
|
||||
delete [] theIDs;
|
||||
|
||||
return display;
|
||||
return new wxDisplayImplMacOSX(n, theIDs[n]);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user