From 5fc82109bab6f51d8be7134f1368f14c628794e9 Mon Sep 17 00:00:00 2001 From: Jan D Date: Wed, 24 Dec 2014 12:24:14 +0100 Subject: [PATCH] Backport: Memory leak fix and 19133 fix. Fixes: debbugs:19133 * nsimage.m (allocInitFromFile:): Initialize bmRep. (dealloc): Release bmRep. (setPixmapData): Make bmRep local so class member is not set. --- src/ChangeLog | 9 ++++++++- src/nsimage.m | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index f98afd8026f..530b9130783 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,11 @@ -2014-11-02 Jan Djärv +2014-12-24 Jan Djärv + + * nsimage.m (allocInitFromFile:): Initialize bmRep. + (dealloc): Release bmRep. + (setPixmapData): Make bmRep local so class member is not + set (Bug#19133). + +2014-12-24 Jan Djärv * nsterm.h (EmacsImage): Remove imageListNext, refCount, reference, imageListSetNext, imageListNext. diff --git a/src/nsimage.m b/src/nsimage.m index cb29bf1b047..a625f20616d 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -174,6 +174,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) image = [[EmacsImage alloc] initByReferencingFile: [NSString stringWithUTF8String: SSDATA (found)]]; + image->bmRep = nil; #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 imgRep = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]]; #else @@ -199,6 +200,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) - (void)dealloc { [stippleMask release]; + [bmRep release]; [super dealloc]; } @@ -245,6 +247,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) if (s >= bits + length) { [bmRep release]; + bmRep = nil; return nil; } #define hexchar(x) ('0' <= (x) && (x) <= '9' ? (x) - '0' : (x) - 'a' + 10) @@ -348,7 +351,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) { if ([rep respondsToSelector: @selector (getBitmapDataPlanes:)]) { - bmRep = (NSBitmapImageRep *) rep; + NSBitmapImageRep *bmRep = (NSBitmapImageRep *) rep; if ([bmRep numberOfPlanes] >= 3) [bmRep getBitmapDataPlanes: pixmapData]; -- 2.39.2