Skip to content

coders/mpc.c colormap potential memory-leak bug #1192

Closed
@fisher2020

Description

@fisher2020

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am using the latest version of ImageMagick
  • I have searched open and closed issues to ensure it has not already been reported

Description

a potential memory leak bug locates in coders/miff.c

Steps to Reproduce

the bug locates in
https://github.com/ImageMagick/ImageMagick/blob/master/coders/mpc.c#L1460
the code frament is as follows: the code locates in a if block,and we allocate colormap memory in the if block, we freed it in normal branch,but forgot free it in exception branch

colormap=(unsigned char *) AcquireQuantumMemory(image->colors,
          packet_size*sizeof(*colormap));
        if (colormap == (unsigned char *) NULL)
          return(MagickFalse);
        /*
          Write colormap to file.
        */
        q=colormap;
        for (i=0; i < (ssize_t) image->colors; i++)
        {
          switch (depth)
          {
            default:
              ThrowWriterException(CorruptImageError,"ImageDepthNotSupported");
            case 32:
            {
              unsigned int
                pixel;

credit: www.vackbot.com ( 墨云科技)

System Configuration

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions