Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

free is Called on Arrays not Allocated by malloc #14

Open
heshuimu opened this issue Dec 25, 2018 · 2 comments
Open

free is Called on Arrays not Allocated by malloc #14

heshuimu opened this issue Dec 25, 2018 · 2 comments

Comments

@heshuimu
Copy link

heshuimu commented Dec 25, 2018

tarkit/DCTar.m

Line 442 in 62d1c23

char buffer[TAR_BLOCK_SIZE];

tarkit/DCTar.m

Lines 454 to 459 in 62d1c23

char nameChar[USTAR_name_size];
[self writeString:path toChar:nameChar withLength:USTAR_name_size];
char unameChar[USTAR_uname_size];
[self writeString:ownerName toChar:unameChar withLength:USTAR_uname_size];
char gnameChar[USTAR_gname_size];
[self writeString:groupName toChar:gnameChar withLength:USTAR_gname_size];

tarkit/DCTar.m

Lines 507 to 510 in 62d1c23

free(buffer);
free(nameChar);
free(unameChar);
free(gnameChar);

This causes runtime exceptions at least on iOS 12. There are several other places where free is called like this, the code snippet above is just an example.

@heshuimu heshuimu changed the title free is called on local arrays free is Called on Local Arrays Dec 25, 2018
@heshuimu heshuimu changed the title free is Called on Local Arrays free is Called on Arrays not Allocated by malloc Dec 25, 2018
@omochi
Copy link

omochi commented May 30, 2019

There are more wrong free.

tarkit/DCTar.m

Line 219 in 2bc2873

free(block);

tarkit/DCTar.m

Line 372 in 2bc2873

free(nameBytes);

tarkit/DCTar.m

Line 384 in 2bc2873

free(sizeBytes);

tarkit/DCTar.m

Line 530 in 2bc2873

free(buffer);

I tried fix these free.
But other bugs are still exists.

@mikehouse
Copy link

I confirm, build from master crashes an app, have to use source code at 0.1.3 tag to fix this. Removing free fixes not all problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants