Commit 1742ae80f for imagemagick.org

commit 1742ae80f1a696bd663714caf88e760000829642
Author: Cristy <urban-warrior@imagemagick.org>
Date:   Thu May 21 06:44:56 2026 -0400

    fix poxxible memory leak

diff --git a/MagickCore/policy.c b/MagickCore/policy.c
index 0cb4cb336..d18cb9814 100644
--- a/MagickCore/policy.c
+++ b/MagickCore/policy.c
@@ -740,7 +740,6 @@ MagickExport MagickBooleanType IsRightsAuthorized(const PolicyDomain domain,
       {
         char
           *canonical_directory,
-          *canonical_path,
           directory[MagickPathExtent];

         GetPathComponent(pattern,HeadPath,directory);
@@ -751,11 +750,17 @@ MagickExport MagickBooleanType IsRightsAuthorized(const PolicyDomain domain,
               MagickFalse);
             canonical_directory=DestroyString(canonical_directory);
           }
-        canonical_path=realpath_utf8(pattern);
-        if ((canonical_path != (char *) NULL) && (match == MagickFalse))
+        if (match == MagickFalse)
           {
-            match=GlobExpression(canonical_path,policy->pattern,MagickFalse);
-            canonical_path=DestroyString(canonical_path);
+            char
+              *canonical_path;
+
+            canonical_path=realpath_utf8(pattern);
+            if (canonical_path != (char *) NULL)
+              {
+                match=GlobExpression(canonical_path,policy->pattern,MagickFalse);
+                canonical_path=DestroyString(canonical_path);
+              }
           }
       }
     if (match == MagickFalse)