#24 Fix a memory leak in profile.c(AppendImageProfile)

closed-fixed
None
5
2011-11-27
2011-04-28
lhelper
No

In method AppendImageProfile(Image *image, const char *name, const unsigned char *profile_chunk, const size_t chunk_length), the pointer 'unsigned char *profile' was allocated via MagickAllocateMemory(unsigned char *,(size_t) profile_length) and it's clone was added onto the image->profiles in method SetImageProfile(), the pointer itself remains, which should be freed.

The following is the patch:
--- GraphicsMagick-1.3.12/magick/profile.c 2009-12-17 02:49:54.000000000 +0800
+++ /opt/mod_imageman/GraphicsMagick-1.3.12/magick/profile.c 2011-04-29 00:44:57.000000000 +0800
@@ -176,6 +176,7 @@
(void) memcpy(profile,existing_profile,existing_length);
(void) memcpy(profile+existing_length,profile_chunk,chunk_length);
status=SetImageProfile(image,name,profile,profile_length);
+ MagickFreeMemory(profile);
}

return status;

Discussion

  • lhelper

    lhelper - 2011-04-28

    Fix a memory leak in profile.c(AppendImageProfile)

     
    Attachments
  • Bob Friesenhahn

    Bob Friesenhahn - 2011-11-27
    • assigned_to: nobody --> bfriesen
    • status: open --> open-fixed
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2011-11-27

    This is fixed via Mercurial changeset c600334ed7b9

    Thanks for the patch.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2011-11-27
    • status: open-fixed --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks