Commit c1811dd3b for imagemagick.org

commit c1811dd3bb22b7d1ca6ce9c454e756b578e92a5d
Author: Cristy <urban-warrior@imagemagick.org>
Date:   Thu Sep 17 19:21:56 2026 -0400

    define GetShreadPasses()

diff --git a/MagickCore/memory.c b/MagickCore/memory.c
index 3847b4024..15d19b472 100644
--- a/MagickCore/memory.c
+++ b/MagickCore/memory.c
@@ -89,6 +89,7 @@
 #include "MagickCore/memory_.h"
 #include "MagickCore/memory-private.h"
 #include "MagickCore/policy.h"
+#include "MagickCore/policy-private.h"
 #include "MagickCore/resource_.h"
 #include "MagickCore/semaphore.h"
 #include "MagickCore/string_.h"
@@ -1678,24 +1679,7 @@ MagickPrivate MagickBooleanType ShredMagickMemory(void *memory,
   if ((memory == NULL) || (length == 0))
     return(MagickFalse);
   if (passes == -1)
-    {
-      char
-        *property;
-
-      passes=0;
-      property=GetEnvironmentValue("MAGICK_SHRED_PASSES");
-      if (property != (char *) NULL)
-        {
-          passes=(ssize_t) StringToInteger(property);
-          property=DestroyString(property);
-        }
-      property=GetPolicyValue("system:shred");
-      if (property != (char *) NULL)
-        {
-          passes=(ssize_t) StringToInteger(property);
-          property=DestroyString(property);
-        }
-    }
+    passes=GetShredPasses();
   if (passes == 0)
     return(MagickTrue);
   /*
diff --git a/MagickCore/policy-private.h b/MagickCore/policy-private.h
index bf115fbea..c55f9193c 100644
--- a/MagickCore/policy-private.h
+++ b/MagickCore/policy-private.h
@@ -22,7 +22,9 @@
 extern "C" {
 #endif

+#include "MagickCore/quantum-private.h"
 #include "MagickCore/resource-private.h"
+#include "MagickCore/string-private.h"
 #include "MagickCore/utility-private.h"

 #if MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
@@ -45,6 +47,36 @@ extern MagickPrivate MagickBooleanType
 extern MagickPrivate void
   PolicyComponentTerminus(void);

+static inline ssize_t GetShredPasses(void)
+{
+  char
+    *option;
+
+  ssize_t
+    policy_passes = 0,
+    env_passes = 0,
+    passes;
+
+  option=GetPolicyValue("system:shred");
+  if (option != (char *) NULL)
+    {
+      policy_passes=(ssize_t) StringToLong(option);
+      option=DestroyString(option);
+      if (policy_passes < 0)
+        return(0);
+    }
+  option=GetEnvironmentValue("MAGICK_SHRED_PASSES");
+  if (option != (char *) NULL)
+    {
+      env_passes=(ssize_t) StringToLong(option);
+      option=DestroyString(option);
+      if (env_passes < 0)
+        return(0);
+    }
+  passes=MagickMax(policy_passes,env_passes);
+  return(passes);
+}
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif