Skip to content

free is Called on Arrays not Allocated by malloc #14

Open

Description

@heshuimu

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.

Activity

  1. changed the title [-]`free` is called on local arrays[/-] [+]`free` is Called on Local Arrays[/+] on Dec 25, 2018
  2. changed the title [-]`free` is Called on Local Arrays[/-] [+]`free` is Called on Arrays not Allocated by `malloc`[/+] on Dec 25, 2018
  3. omochi commented on May 30, 2019

    @omochi

    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.

  4. mikehouse commented on Jul 20, 2020

    @mikehouse

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions