Skip to content

Commit 8a83894

Browse files
author
Michael Potter
committed
Fix color space memory leak
1 parent 5ad370d commit 8a83894

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

FastImageCache/FICImageTable.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ - (void)setEntryForEntityUUID:(NSString *)entityUUID sourceImageUUID:(NSString *
270270

271271
// Create context whose backing store *is* the mapped file data
272272
FICImageTableEntry *entryData = [self _entryDataAtIndex:newEntryIndex];
273-
if (entryData) {
273+
if (entryData != nil) {
274274
[entryData setEntityUUIDBytes:FICUUIDBytesWithString(entityUUID)];
275275
[entryData setSourceImageUUIDBytes:FICUUIDBytesWithString(sourceImageUUID)];
276276

@@ -290,7 +290,6 @@ - (void)setEntryForEntityUUID:(NSString *)entityUUID sourceImageUUID:(NSString *
290290
[_lock unlock];
291291

292292
CGContextRef context = CGBitmapContextCreate([entryData bytes], pixelSize.width, pixelSize.height, bitsPerComponent, _imageRowLength, colorSpace, bitmapInfo);
293-
CGColorSpaceRelease(colorSpace);
294293

295294
CGContextTranslateCTM(context, 0, pixelSize.height);
296295
CGContextScaleCTM(context, _screenScale, -_screenScale);
@@ -306,6 +305,8 @@ - (void)setEntryForEntityUUID:(NSString *)entityUUID sourceImageUUID:(NSString *
306305
} else {
307306
[_lock unlock];
308307
}
308+
309+
CGColorSpaceRelease(colorSpace);
309310
} else {
310311
[_lock unlock];
311312
}

0 commit comments

Comments
 (0)