]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sun, 7 Oct 2012 20:39:52 +0000 (20:39 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sun, 7 Oct 2012 20:39:52 +0000 (20:39 +0000)
MagickCore/fx.c

index d601d368c79aee6320bff07e94337b60bc7f96cf..aa9fc31aef698adfb7495d23f6e524590fde5ca9 100644 (file)
@@ -2994,7 +2994,11 @@ static FxInfo **AcquireFxThreadSet(const Image *image,const char *expression,
   number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
   fx_info=(FxInfo **) AcquireQuantumMemory(number_threads,sizeof(*fx_info));
   if (fx_info == (FxInfo **) NULL)
-    return((FxInfo **) NULL);
+    {
+      (void) ThrowMagickException(exception,GetMagickModule(),
+        ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
+      return((FxInfo **) NULL);
+    }
   (void) ResetMagickMemory(fx_info,0,number_threads*sizeof(*fx_info));
   if (*expression != '@')
     fx_expression=ConstantString(expression);
@@ -3002,12 +3006,19 @@ static FxInfo **AcquireFxThreadSet(const Image *image,const char *expression,
     fx_expression=FileToString(expression+1,~0,exception);
   for (i=0; i < (ssize_t) number_threads; i++)
   {
+    MagickBooleanType
+      status;
+
     fx_info[i]=AcquireFxInfo(image,fx_expression,exception);
     if (fx_info[i] == (FxInfo *) NULL)
-      return(DestroyFxThreadSet(fx_info));
-    (void) FxPreprocessExpression(fx_info[i],&alpha,fx_info[i]->exception);
+      break;
+    status=FxPreprocessExpression(fx_info[i],&alpha,exception);
+    if (status == MagickFalse)
+      break;
   }
   fx_expression=DestroyString(fx_expression);
+  if (i < (ssize_t) number_threads)
+    fx_info=DestroyFxThreadSet(fx_info);
   return(fx_info);
 }
 
@@ -3032,9 +3043,6 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
   MagickOffsetType
     progress;
 
-  double
-    alpha;
-
   ssize_t
     y;
 
@@ -3042,25 +3050,19 @@ MagickExport Image *FxImage(const Image *image,const char *expression,
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+  fx_info=AcquireFxThreadSet(image,expression,exception);
+  if (fx_info == (FxInfo **) NULL)
+    return((Image *) NULL);
   fx_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
   if (fx_image == (Image *) NULL)
-    return((Image *) NULL);
-  if (SetImageStorageClass(fx_image,DirectClass,exception) == MagickFalse)
     {
-      fx_image=DestroyImage(fx_image);
+      fx_info=DestroyFxThreadSet(fx_info);
       return((Image *) NULL);
     }
-  fx_info=AcquireFxThreadSet(image,expression,exception);
-  if (fx_info == (FxInfo **) NULL)
-    {
-      fx_image=DestroyImage(fx_image);
-      ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
-    }
-  status=FxPreprocessExpression(fx_info[0],&alpha,exception);
-  if (status == MagickFalse)
+  if (SetImageStorageClass(fx_image,DirectClass,exception) == MagickFalse)
     {
-      fx_image=DestroyImage(fx_image);
       fx_info=DestroyFxThreadSet(fx_info);
+      fx_image=DestroyImage(fx_image);
       return((Image *) NULL);
     }
   /*