[PATCH] DestroyContributionThreadSet() segfaults

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
PHO
Posts: 1
Joined: 2012-07-30T01:47:27-07:00
Authentication code: 15

[PATCH] DestroyContributionThreadSet() segfaults

Post by PHO »

On ImageMagick-6.7.8-6 and possibly the trunk, DestroyContributionThreadSet() in magick/resize.c segfaults when the following condition is met, which is usually the case:

Code: Select all

GetMagickResourceLimit(ThreadResource) > GetOpenMPMaximumThreads()
Here is a patch to fix it:

Code: Select all

diff -urN ImageMagick-6.7.8-6.orig/magick/resize.c ImageMagick-6.7.8-6/magick/resize.c
--- ImageMagick-6.7.8-6.orig/magick/resize.c	2012-07-30 17:12:20.000000000 +0900
+++ ImageMagick-6.7.8-6/magick/resize.c	2012-07-30 17:12:44.000000000 +0900
@@ -2097,7 +2097,7 @@
     i;
 
   assert(contribution != (ContributionInfo **) NULL);
-  for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); i++)
+  for (i=0; i < (ssize_t) GetOpenMPMaximumThreads(); i++)
     if (contribution[i] != (ContributionInfo *) NULL)
       contribution[i]=(ContributionInfo *) RelinquishAlignedMemory(
         contribution[i]);
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: [PATCH] DestroyContributionThreadSet() segfaults

Post by magick »

Thanks for the problem report and patch. We'll add it to the Subversion repository by sometime tomorrow.
Post Reply