From: Jan D Date: Wed, 24 Dec 2014 11:24:14 +0000 (+0100) Subject: Backport: Memory leak fix and 19133 fix. X-Git-Tag: emacs-24.4.90~110 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5fc8210;p=emacs.git 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. --- 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];