Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#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
    • assigned_to: nobody --> bfriesen
    • status: open --> open-fixed
     
  • This is fixed via Mercurial changeset c600334ed7b9

    Thanks for the patch.

     
    • status: open-fixed --> closed-fixed