]> granicus.if.org Git - imagemagick/commitdiff
https://oss-fuzz.com/v2/testcase-detail/6603020772048896?noredirect=1
authorCristy <urban-warrior@imagemagick.org>
Wed, 7 Mar 2018 01:29:47 +0000 (20:29 -0500)
committerCristy <urban-warrior@imagemagick.org>
Wed, 7 Mar 2018 01:29:47 +0000 (20:29 -0500)
MagickCore/fx.c

index 1c36397fa01cbda8ee2335e98cbd64ea3eb2a24c..583a478dfe2f607d503578e83890015764162070 100644 (file)
@@ -2097,10 +2097,15 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
   const char *expression,size_t *depth,double *beta,ExceptionInfo *exception)
 {
 #define FxMaxParenthesisDepth  58
+#define FxResult(x) \
+{ \
+  subexpression=DestroyString(subexpression); \
+  return(x); \
+}
 
   char
     *q,
-    subexpression[MagickPathExtent];
+    *subexpression;
 
   double
     alpha,
@@ -2110,18 +2115,19 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     *p;
 
   *beta=0.0;
+  subexpression=AcquireString((const char *) NULL);
   if (*depth > MagickMaxRecursionDepth)
     {
       (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
         "UnableToParseExpression","`%s'",expression);
-      return(0.0);
+      FxResult(0.0);
     }
   if (exception->severity >= ErrorException)
-    return(0.0);
+    FxResult(0.0);
   while (isspace((int) ((unsigned char) *expression)) != 0)
     expression++;
   if (*expression == '\0')
-    return(0.0);
+    FxResult(0.0);
   *subexpression='\0';
   p=FxOperatorPrecedence(expression,exception);
   if (p != (const char *) NULL)
@@ -2137,26 +2143,26 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
           *beta=(double) (~(size_t) *beta);
-          return(*beta);
+          FxResult(*beta);
         }
         case '!':
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
-          return(*beta == 0.0 ? 1.0 : 0.0);
+          FxResult(*beta == 0.0 ? 1.0 : 0.0);
         }
         case '^':
         {
           *beta=pow(alpha,FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,
             beta,exception));
-          return(*beta);
+          FxResult(*beta);
         }
         case '*':
         case ExponentialNotation:
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
-          return(alpha*(*beta));
+          FxResult(alpha*(*beta));
         }
         case '/':
         {
@@ -2166,9 +2172,9 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
                 OptionError,"DivideByZero","`%s'",expression);
-              return(0.0);
+              FxResult(0.0);
             }
-          return(alpha/(*beta));
+          FxResult(alpha/(*beta));
         }
         case '%':
         {
@@ -2179,21 +2185,21 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
                 OptionError,"DivideByZero","`%s'",expression);
-              return(0.0);
+              FxResult(0.0);
             }
-          return(fmod(alpha,*beta));
+          FxResult(fmod(alpha,*beta));
         }
         case '+':
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
-          return(alpha+(*beta));
+          FxResult(alpha+(*beta));
         }
         case '-':
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
-          return(alpha-(*beta));
+          FxResult(alpha-(*beta));
         }
         case LeftShiftOperator:
         {
@@ -2203,10 +2209,10 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
                 OptionError,"ShiftCountOverflow","`%s'",subexpression);
-              return(0.0);
+              FxResult(0.0);
             }
           *beta=(double) ((size_t) (alpha+0.5) << (size_t) (gamma+0.5));
-          return(*beta);
+          FxResult(*beta);
         }
         case RightShiftOperator:
         {
@@ -2216,60 +2222,60 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
                 OptionError,"ShiftCountOverflow","`%s'",subexpression);
-              return(0.0);
+              FxResult(0.0);
             }
           *beta=(double) ((size_t) (alpha+0.5) >> (size_t) (gamma+0.5));
-          return(*beta);
+          FxResult(*beta);
         }
         case '<':
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
-          return(alpha < *beta ? 1.0 : 0.0);
+          FxResult(alpha < *beta ? 1.0 : 0.0);
         }
         case LessThanEqualOperator:
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
-          return(alpha <= *beta ? 1.0 : 0.0);
+          FxResult(alpha <= *beta ? 1.0 : 0.0);
         }
         case '>':
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
-          return(alpha > *beta ? 1.0 : 0.0);
+          FxResult(alpha > *beta ? 1.0 : 0.0);
         }
         case GreaterThanEqualOperator:
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
-          return(alpha >= *beta ? 1.0 : 0.0);
+          FxResult(alpha >= *beta ? 1.0 : 0.0);
         }
         case EqualOperator:
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
-          return(fabs(alpha-(*beta)) < MagickEpsilon ? 1.0 : 0.0);
+          FxResult(fabs(alpha-(*beta)) < MagickEpsilon ? 1.0 : 0.0);
         }
         case NotEqualOperator:
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
-          return(fabs(alpha-(*beta)) >= MagickEpsilon ? 1.0 : 0.0);
+          FxResult(fabs(alpha-(*beta)) >= MagickEpsilon ? 1.0 : 0.0);
         }
         case '&':
         {
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
           *beta=(double) ((size_t) (alpha+0.5) & (size_t) (gamma+0.5));
-          return(*beta);
+          FxResult(*beta);
         }
         case '|':
         {
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
           *beta=(double) ((size_t) (alpha+0.5) | (size_t) (gamma+0.5));
-          return(*beta);
+          FxResult(*beta);
         }
         case LogicalAndOperator:
         {
@@ -2277,12 +2283,12 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
           if (alpha <= 0.0)
             {
               *beta=0.0;
-              return(*beta);
+              FxResult(*beta);
             }
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,p,depth,beta,
             exception);
           *beta=(gamma > 0.0) ? 1.0 : 0.0;
-          return(*beta);
+          FxResult(*beta);
         }
         case LogicalOrOperator:
         {
@@ -2290,12 +2296,12 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
           if (alpha > 0.0)
             {
              *beta=1.0;
-             return(*beta);
+             FxResult(*beta);
             }
           gamma=FxEvaluateSubexpression(fx_info,channel,x,y,p,depth,beta,
             exception);
           *beta=(gamma > 0.0) ? 1.0 : 0.0;
-          return(*beta);
+          FxResult(*beta);
         }
         case '?':
         {
@@ -2306,7 +2312,7 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
                 OptionError,"UnableToParseExpression","`%s'",subexpression);
-              return(0.0);
+              FxResult(0.0);
             }
           if (fabs(alpha) >= MagickEpsilon)
             gamma=FxEvaluateSubexpression(fx_info,channel,x,y,p,depth,beta,
@@ -2314,7 +2320,7 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
           else
             gamma=FxEvaluateSubexpression(fx_info,channel,x,y,q,depth,beta,
               exception);
-          return(gamma);
+          FxResult(gamma);
         }
         case '=':
         {
@@ -2328,7 +2334,7 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
             {
               (void) ThrowMagickException(exception,GetMagickModule(),
                 OptionError,"UnableToParseExpression","`%s'",subexpression);
-              return(0.0);
+              FxResult(0.0);
             }
           ClearMagickException(exception);
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
@@ -2337,25 +2343,25 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
           (void) DeleteNodeFromSplayTree(fx_info->symbols,subexpression);
           (void) AddValueToSplayTree(fx_info->symbols,ConstantString(
             subexpression),ConstantString(numeric));
-          return(*beta);
+          FxResult(*beta);
         }
         case ',':
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
-          return(alpha);
+          FxResult(alpha);
         }
         case ';':
         {
           *beta=FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,beta,
             exception);
-          return(*beta);
+          FxResult(*beta);
         }
         default:
         {
           gamma=alpha*FxEvaluateSubexpression(fx_info,channel,x,y,++p,depth,
             beta,exception);
-          return(gamma);
+          FxResult(gamma);
         }
       }
     }
@@ -2370,7 +2376,7 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
       gamma=FxEvaluateSubexpression(fx_info,channel,x,y,subexpression,depth,
         beta,exception);
       (*depth)--;
-      return(gamma);
+      FxResult(gamma);
     }
   switch (*expression)
   {
@@ -2378,19 +2384,19 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     {
       gamma=FxEvaluateSubexpression(fx_info,channel,x,y,expression+1,depth,beta,
         exception);
-      return(1.0*gamma);
+      FxResult(1.0*gamma);
     }
     case '-':
     {
       gamma=FxEvaluateSubexpression(fx_info,channel,x,y,expression+1,depth,beta,
         exception);
-      return(-1.0*gamma);
+      FxResult(-1.0*gamma);
     }
     case '~':
     {
       gamma=FxEvaluateSubexpression(fx_info,channel,x,y,expression+1,depth,beta,
         exception);
-      return((double) (~(size_t) (gamma+0.5)));
+      FxResult((double) (~(size_t) (gamma+0.5)));
     }
     case 'A':
     case 'a':
@@ -2399,21 +2405,21 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return(fabs(alpha));
+          FxResult(fabs(alpha));
         }
 #if defined(MAGICKCORE_HAVE_ACOSH)
       if (LocaleNCompare(expression,"acosh",5) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
             beta,exception);
-          return(acosh(alpha));
+          FxResult(acosh(alpha));
         }
 #endif
       if (LocaleNCompare(expression,"acos",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
             beta,exception);
-          return(acos(alpha));
+          FxResult(acos(alpha));
         }
 #if defined(MAGICKCORE_HAVE_J1)
       if (LocaleNCompare(expression,"airy",4) == 0)
@@ -2421,9 +2427,9 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
             beta,exception);
           if (alpha == 0.0)
-            return(1.0);
+            FxResult(1.0);
           gamma=2.0*j1((MagickPI*alpha))/(MagickPI*alpha);
-          return(gamma*gamma);
+          FxResult(gamma*gamma);
         }
 #endif
 #if defined(MAGICKCORE_HAVE_ASINH)
@@ -2431,50 +2437,50 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
             beta,exception);
-          return(asinh(alpha));
+          FxResult(asinh(alpha));
         }
 #endif
       if (LocaleNCompare(expression,"asin",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
             beta,exception);
-          return(asin(alpha));
+          FxResult(asin(alpha));
         }
       if (LocaleNCompare(expression,"alt",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return(((ssize_t) alpha) & 0x01 ? -1.0 : 1.0);
+          FxResult(((ssize_t) alpha) & 0x01 ? -1.0 : 1.0);
         }
       if (LocaleNCompare(expression,"atan2",5) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
             beta,exception);
-          return(atan2(alpha,*beta));
+          FxResult(atan2(alpha,*beta));
         }
 #if defined(MAGICKCORE_HAVE_ATANH)
       if (LocaleNCompare(expression,"atanh",5) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
             beta,exception);
-          return(atanh(alpha));
+          FxResult(atanh(alpha));
         }
 #endif
       if (LocaleNCompare(expression,"atan",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
             beta,exception);
-          return(atan(alpha));
+          FxResult(atan(alpha));
         }
       if (LocaleCompare(expression,"a") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'B':
     case 'b':
     {
       if (LocaleCompare(expression,"b") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'C':
@@ -2484,32 +2490,32 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
             beta,exception);
-          return(ceil(alpha));
+          FxResult(ceil(alpha));
         }
       if (LocaleNCompare(expression,"clamp",5) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
             beta,exception);
           if (alpha < 0.0)
-            return(0.0);
+            FxResult(0.0);
           if (alpha > 1.0)
-            return(1.0);
-          return(alpha);
+            FxResult(1.0);
+          FxResult(alpha);
         }
       if (LocaleNCompare(expression,"cosh",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
             beta,exception);
-          return(cosh(alpha));
+          FxResult(cosh(alpha));
         }
       if (LocaleNCompare(expression,"cos",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return(cos(alpha));
+          FxResult(cos(alpha));
         }
       if (LocaleCompare(expression,"c") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'D':
@@ -2548,13 +2554,13 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
             (void) FormatLocaleFile(fx_info->file,"%s[%.20g,%.20g].%s: "
               "%s=%.*g\n",fx_info->images->filename,(double) x,(double) y,type,
               subexpression,GetMagickPrecision(),alpha);
-          return(0.0);
+          FxResult(0.0);
         }
       if (LocaleNCompare(expression,"drc",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return((alpha/(*beta*(alpha-1.0)+1.0)));
+          FxResult((alpha/(*beta*(alpha-1.0)+1.0)));
         }
       break;
     }
@@ -2562,23 +2568,23 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     case 'e':
     {
       if (LocaleCompare(expression,"epsilon") == 0)
-        return(MagickEpsilon);
+        FxResult(MagickEpsilon);
 #if defined(MAGICKCORE_HAVE_ERF)
       if (LocaleNCompare(expression,"erf",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return(erf(alpha));
+          FxResult(erf(alpha));
         }
 #endif
       if (LocaleNCompare(expression,"exp",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return(exp(alpha));
+          FxResult(exp(alpha));
         }
       if (LocaleCompare(expression,"e") == 0)
-        return(2.7182818284590452354);
+        FxResult(2.7182818284590452354);
       break;
     }
     case 'F':
@@ -2588,7 +2594,7 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
             beta,exception);
-          return(floor(alpha));
+          FxResult(floor(alpha));
         }
       break;
     }
@@ -2600,7 +2606,7 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
             beta,exception);
           gamma=exp((-alpha*alpha/2.0))/sqrt(2.0*MagickPI);
-          return(gamma);
+          FxResult(gamma);
         }
       if (LocaleNCompare(expression,"gcd",3) == 0)
         {
@@ -2611,24 +2617,24 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
             beta,exception);
           gcd=FxGCD((MagickOffsetType) (alpha+0.5),(MagickOffsetType) (*beta+
             0.5));
-          return((double) gcd);
+          FxResult((double) gcd);
         }
       if (LocaleCompare(expression,"g") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'H':
     case 'h':
     {
       if (LocaleCompare(expression,"h") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       if (LocaleCompare(expression,"hue") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       if (LocaleNCompare(expression,"hypot",5) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
             beta,exception);
-          return(hypot(alpha,*beta));
+          FxResult(hypot(alpha,*beta));
         }
       break;
     }
@@ -2636,41 +2642,41 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
     case 'k':
     {
       if (LocaleCompare(expression,"k") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'I':
     case 'i':
     {
       if (LocaleCompare(expression,"intensity") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       if (LocaleNCompare(expression,"int",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return(floor(alpha));
+          FxResult(floor(alpha));
         }
       if (LocaleNCompare(expression,"isnan",5) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
             beta,exception);
-          return((double) !!IsNaN(alpha));
+          FxResult((double) !!IsNaN(alpha));
         }
       if (LocaleCompare(expression,"i") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'J':
     case 'j':
     {
       if (LocaleCompare(expression,"j") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
 #if defined(MAGICKCORE_HAVE_J0)
       if (LocaleNCompare(expression,"j0",2) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,depth,
             beta,exception);
-          return(j0(alpha));
+          FxResult(j0(alpha));
         }
 #endif
 #if defined(MAGICKCORE_HAVE_J1)
@@ -2678,7 +2684,7 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,depth,
             beta,exception);
-          return(j1(alpha));
+          FxResult(j1(alpha));
         }
 #endif
 #if defined(MAGICKCORE_HAVE_J1)
@@ -2687,9 +2693,9 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
             beta,exception);
           if (alpha == 0.0)
-            return(1.0);
+            FxResult(1.0);
           gamma=(2.0*j1((MagickPI*alpha))/(MagickPI*alpha));
-          return(gamma);
+          FxResult(gamma);
         }
 #endif
       break;
@@ -2701,36 +2707,36 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+2,depth,
             beta,exception);
-          return(log(alpha));
+          FxResult(log(alpha));
         }
       if (LocaleNCompare(expression,"logtwo",6) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+6,depth,
             beta,exception);
-          return(log10(alpha))/log10(2.0);
+          FxResult(log10(alpha)/log10(2.0));
         }
       if (LocaleNCompare(expression,"log",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return(log10(alpha));
+          FxResult(log10(alpha));
         }
       if (LocaleCompare(expression,"lightness") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'M':
     case 'm':
     {
       if (LocaleCompare(expression,"MaxRGB") == 0)
-        return(QuantumRange);
+        FxResult(QuantumRange);
       if (LocaleNCompare(expression,"maxima",6) == 0)
         break;
       if (LocaleNCompare(expression,"max",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return(alpha > *beta ? alpha : *beta);
+          FxResult(alpha > *beta ? alpha : *beta);
         }
       if (LocaleNCompare(expression,"minima",6) == 0)
         break;
@@ -2738,17 +2744,17 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return(alpha < *beta ? alpha : *beta);
+          FxResult(alpha < *beta ? alpha : *beta);
         }
       if (LocaleNCompare(expression,"mod",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
           gamma=alpha-floor((alpha/(*beta)))*(*beta);
-          return(gamma);
+          FxResult(gamma);
         }
       if (LocaleCompare(expression,"m") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'N':
@@ -2758,45 +2764,45 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return((double) (alpha < MagickEpsilon));
+          FxResult((double) (alpha < MagickEpsilon));
         }
       if (LocaleCompare(expression,"n") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'O':
     case 'o':
     {
       if (LocaleCompare(expression,"Opaque") == 0)
-        return(1.0);
+        FxResult(1.0);
       if (LocaleCompare(expression,"o") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'P':
     case 'p':
     {
       if (LocaleCompare(expression,"phi") == 0)
-        return(MagickPHI);
+        FxResult(MagickPHI);
       if (LocaleCompare(expression,"pi") == 0)
-        return(MagickPI);
+        FxResult(MagickPI);
       if (LocaleNCompare(expression,"pow",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return(pow(alpha,*beta));
+          FxResult(pow(alpha,*beta));
         }
       if (LocaleCompare(expression,"p") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'Q':
     case 'q':
     {
       if (LocaleCompare(expression,"QuantumRange") == 0)
-        return(QuantumRange);
+        FxResult(QuantumRange);
       if (LocaleCompare(expression,"QuantumScale") == 0)
-        return(QuantumScale);
+        FxResult(QuantumScale);
       break;
     }
     case 'R':
@@ -2808,64 +2814,64 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         #pragma omp critical (MagickCore_FxEvaluateSubexpression)
 #endif
           alpha=GetPseudoRandomValue(fx_info->random_info);
-          return(alpha);
+          FxResult(alpha);
         }
       if (LocaleNCompare(expression,"round",5) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
             beta,exception);
-          return(floor(alpha+0.5));
+          FxResult(floor(alpha+0.5));
         }
       if (LocaleCompare(expression,"r") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'S':
     case 's':
     {
       if (LocaleCompare(expression,"saturation") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       if (LocaleNCompare(expression,"sign",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
             beta,exception);
-          return(alpha < 0.0 ? -1.0 : 1.0);
+          FxResult(alpha < 0.0 ? -1.0 : 1.0);
         }
       if (LocaleNCompare(expression,"sinc",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
             beta,exception);
           if (alpha == 0)
-            return(1.0);
+            FxResult(1.0);
           gamma=sin((MagickPI*alpha))/(MagickPI*alpha);
-          return(gamma);
+          FxResult(gamma);
         }
       if (LocaleNCompare(expression,"sinh",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
             beta,exception);
-          return(sinh(alpha));
+          FxResult(sinh(alpha));
         }
       if (LocaleNCompare(expression,"sin",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return(sin(alpha));
+          FxResult(sin(alpha));
         }
       if (LocaleNCompare(expression,"sqrt",4) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
             beta,exception);
-          return(sqrt(alpha));
+          FxResult(sqrt(alpha));
         }
       if (LocaleNCompare(expression,"squish",6) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+6,depth,
             beta,exception);
-          return((1.0/(1.0+exp(-alpha))));
+          FxResult((1.0/(1.0+exp(-alpha))));
         }
       if (LocaleCompare(expression,"s") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'T':
@@ -2875,40 +2881,40 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+4,depth,
             beta,exception);
-          return(tanh(alpha));
+          FxResult(tanh(alpha));
         }
       if (LocaleNCompare(expression,"tan",3) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+3,depth,
             beta,exception);
-          return(tan(alpha));
+          FxResult(tan(alpha));
         }
       if (LocaleCompare(expression,"Transparent") == 0)
-        return(0.0);
+        FxResult(0.0);
       if (LocaleNCompare(expression,"trunc",5) == 0)
         {
           alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,depth,
             beta,exception);
           if (alpha >= 0.0)
-            return(floor(alpha));
-          return(ceil(alpha));
+            FxResult(floor(alpha));
+          FxResult(ceil(alpha));
         }
       if (LocaleCompare(expression,"t") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'U':
     case 'u':
     {
       if (LocaleCompare(expression,"u") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'V':
     case 'v':
     {
       if (LocaleCompare(expression,"v") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'W':
@@ -2921,24 +2927,24 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
             alpha=FxEvaluateSubexpression(fx_info,channel,x,y,expression+5,
               depth,beta,exception);
           } while (fabs(alpha) >= MagickEpsilon);
-          return(*beta);
+          FxResult(*beta);
         }
       if (LocaleCompare(expression,"w") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'Y':
     case 'y':
     {
       if (LocaleCompare(expression,"y") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     case 'Z':
     case 'z':
     {
       if (LocaleCompare(expression,"z") == 0)
-        return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+        FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
       break;
     }
     default:
@@ -2947,8 +2953,8 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,
   q=(char *) expression;
   alpha=InterpretSiPrefixValue(expression,&q);
   if (q == expression)
-    return(FxGetSymbol(fx_info,channel,x,y,expression,exception));
-  return(alpha);
+    FxResult(FxGetSymbol(fx_info,channel,x,y,expression,exception));
+  FxResult(alpha);
 }
 
 MagickPrivate MagickBooleanType FxEvaluateExpression(FxInfo *fx_info,