Skip to content

Commit

Permalink
Fix leak
Browse files Browse the repository at this point in the history
  • Loading branch information
dhinakg committed Aug 19, 2024
1 parent f0b61cc commit 9d2e33c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/extract_standalone.m
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,18 @@ int extractAssetStandalone(AAByteStream byteStream, ExtractionConfiguration* con
break;
}

CFTypeRef configCopy = CFBridgingRetain([config copyWithFunction:(yop == AA_YOP_TYPE_DST_FIXUP ? @"VERIFY" : @"EXTRACT")]);

// TODO: What is the difference between these two?
// TODO: Magic constant
// TODO: CFBridgingRetain will leak
AAArchiveStream extractStream =
yop == AA_YOP_TYPE_DST_FIXUP
? AAVerifyDirectoryArchiveOutputStreamOpen(config.outputPath.UTF8String, keySet,
(void*)CFBridgingRetain([config copyWithFunction:@"VERIFY"]),
aa_callback, UINT64_C(1) << 53, 0)
: AAExtractArchiveOutputStreamOpen(config.outputPath.UTF8String,
(void*)CFBridgingRetain([config copyWithFunction:@"EXTRACT"]), aa_callback, 0,
0);
? AAVerifyDirectoryArchiveOutputStreamOpen(config.outputPath.UTF8String, keySet, (void*)configCopy, aa_callback,
UINT64_C(1) << 53, 0)
: AAExtractArchiveOutputStreamOpen(config.outputPath.UTF8String, (void*)configCopy, aa_callback, 0, 0);
if (!extractStream) {
ERRLOG(@"Failed to open extract stream");
CFRelease(configCopy);
AAArchiveStreamClose(innerDecodeStream);
AAByteStreamClose(decompressStream);
AAByteStreamClose(datStream);
Expand All @@ -258,13 +257,15 @@ int extractAssetStandalone(AAByteStream byteStream, ExtractionConfiguration* con
aa_callback, 0, 0) < 0) {
ERRLOG(@"Failed to process archive stream");
AAArchiveStreamClose(extractStream);
CFRelease(configCopy);
AAArchiveStreamClose(innerDecodeStream);
AAByteStreamClose(decompressStream);
AAByteStreamClose(datStream);
break;
}

AAArchiveStreamClose(extractStream);
CFRelease(configCopy);
AAArchiveStreamClose(innerDecodeStream);
AAByteStreamClose(decompressStream);
AAByteStreamClose(datStream);
Expand Down

0 comments on commit 9d2e33c

Please sign in to comment.