-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a major memory leak in CSBzip2Handle (#158)
* Added a unit test to ease memory leak analysis * Core Bzip2 memory leak fix --------- Co-authored-by: Aurelien HUGELE <[email protected]>
- Loading branch information
1 parent
b75c05b
commit 881e0ec
Showing
4 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// XADZippedBzip2LeakTests.m | ||
// XADMasterTests | ||
// | ||
// Created by aure on 03/02/2022. | ||
// | ||
|
||
#import <XCTest/XCTest.h> | ||
|
||
#import "../CSMemoryHandle.h" | ||
#import "../XADZipParser.h" | ||
#import "../XADBzip2Parser.h" | ||
|
||
|
||
@interface XADZippedBzip2LeakTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation XADZippedBzip2LeakTests | ||
|
||
- (void)testNoLeak { | ||
|
||
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"eicar" ofType:@"bz"]; | ||
|
||
XADError error; | ||
XADArchiveParser *parser = [XADArchiveParser archiveParserForPath:path error:&error]; | ||
NSLog(@"Parser for eicar.bz: %@", parser); | ||
XADHandle *handle = [parser handleForEntryWithDictionary:[parser properties] wantChecksum:NO]; | ||
NSLog(@"handle eicar.bz: %@", handle); | ||
|
||
// to get the total size, just seek to end and reset offset to 0. Should be 68 | ||
[handle seekToEndOfFile]; | ||
off_t size = [handle offsetInFile]; | ||
[handle seekToFileOffset:0]; | ||
|
||
NSData *data = [handle readDataOfLengthAtMost:(int)size]; | ||
NSLog(@"read data:%@",data); | ||
|
||
sleep(10); // to ensure leaks analysis occured in Instruments. | ||
} | ||
|
||
|
||
|
||
@end |
Binary file not shown.