From 9be5faa95009cb866c1f248b7011d836fca5a6ce Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 15 Jul 2012 10:07:16 +1000 Subject: Memory for image was used after being freed. Fixed. --- cocoa/PlatCocoa.mm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cocoa') diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 937edbf00..37334043e 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -620,6 +620,11 @@ void Scintilla::SurfaceImpl::AlphaRectangle(PRectangle rc, int /*cornerSize*/, C } } +static void ProviderReleaseData(void *, const void *data, size_t) { + const unsigned char *pixels = reinterpret_cast(data); + delete []pixels; +} + static CGImageRef ImageCreateFromRGBA(int width, int height, const unsigned char *pixelsImage, bool invert) { CGImageRef image = 0; @@ -631,9 +636,8 @@ static CGImageRef ImageCreateFromRGBA(int width, int height, const unsigned char // Create a data provider. CGDataProviderRef dataProvider = 0; - unsigned char *pixelsUpsideDown = 0; if (invert) { - pixelsUpsideDown = new unsigned char[bitmapByteCount]; + unsigned char *pixelsUpsideDown = new unsigned char[bitmapByteCount]; for (int y=0; y