From 2ee3a1c7995a072b968ce0681f0140f751dc5a70 Mon Sep 17 00:00:00 2001 From: Dov Frankel Date: Thu, 18 Oct 2018 18:14:24 -0400 Subject: [PATCH] Fixed memory leak during buffered extraction from Swift caller (Issue #70) --- Classes/URKArchive.mm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Classes/URKArchive.mm b/Classes/URKArchive.mm index 60616e9..d00c3b8 100644 --- a/Classes/URKArchive.mm +++ b/Classes/URKArchive.mm @@ -1162,12 +1162,14 @@ int CALLBACK BufferedReadCallbackProc(UINT msg, long UserData, long P1, long P2) BOOL (^bufferedReadBlock)(NSData*) = (__bridge BOOL(^)(NSData*))(void *)UserData; if (msg == UCM_PROCESSDATA) { - URKLogDebug("msg: UCM_PROCESSDATA; Copying data chunk and calling read block"); - NSData *dataChunk = [NSData dataWithBytes:(UInt8 *)P1 length:P2]; - BOOL cancelRequested = !bufferedReadBlock(dataChunk); - - if (cancelRequested) { - return -1; + @autoreleasepool { + URKLogDebug("msg: UCM_PROCESSDATA; Copying data chunk and calling read block"); + NSData *dataChunk = [NSData dataWithBytes:(UInt8 *)P1 length:P2]; + BOOL cancelRequested = !bufferedReadBlock(dataChunk); + + if (cancelRequested) { + return -1; + } } }