From 3dd1d4d9158aa3ca58b3eaf7ff8c6411228cfb7f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 21 Feb 2014 00:51:46 +0000 Subject: [PATCH] Fix memory leak in case of error in wxOSX graphics code. Delete the pointer before returning from the function if we don't pass its ownership to CGDataProviderCreateWithData(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75955 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/carbon/graphics.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index 0fb0c50e22..cf5e9a28fd 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -2977,7 +2977,10 @@ CGDataProviderRef wxMacCGDataProviderCreateWithMemoryBuffer( const wxMemoryBuffe { wxMemoryBuffer* b = new wxMemoryBuffer( buf ); if ( b->GetDataLen() == 0 ) + { + delete b; return NULL; + } return CGDataProviderCreateWithData( b , (const void *) b->GetData() , b->GetDataLen() , wxMacReleaseMemoryBufferProviderCallback );