Commit 7693c8f92 for imagemagick.org

commit 7693c8f92b00b17847c444a7223105d670896ad0
Author: Cristy <urban-warrior@imagemagick.org>
Date:   Fri Dec 4 11:30:19 2026 -0500

    never leave the caller with an uninitialized extent

diff --git a/MagickCore/memory-private.h b/MagickCore/memory-private.h
index 075064d57..0373668e5 100644
--- a/MagickCore/memory-private.h
+++ b/MagickCore/memory-private.h
@@ -18,6 +18,9 @@
 #ifndef MAGICKCORE_MEMORY_PRIVATE_H
 #define MAGICKCORE_MEMORY_PRIVATE_H

+#include <errno.h>
+#include <stddef.h>
+#include <stdint.h>
 #include "MagickCore/magick-config.h"

 #if defined(__cplusplus) || defined(c_plusplus)
@@ -32,16 +35,20 @@ extern "C" {

 #define CACHE_ALIGNED(n)  MAGICKCORE_ALIGN_UP(n,CACHE_LINE_SIZE)

-#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 6))
-#if !defined(__ICC)
+#if defined(__has_builtin)
+#  if __has_builtin(__builtin_assume_aligned)
+#    define MAGICK_HAVE_ASSUME_ALIGNED
+#  endif
+#elif (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 6))
+#  define MAGICK_HAVE_ASSUME_ALIGNED
+#endif
+
+#if defined(MAGICK_HAVE_ASSUME_ALIGNED) && !defined(__ICC)
 #define MagickAssumeAligned(address) \
   __builtin_assume_aligned((address),CACHE_LINE_SIZE)
 #else
 #define MagickAssumeAligned(address)  (address)
 #endif
-#else
-#define MagickAssumeAligned(address)  (address)
-#endif

 static inline MagickBooleanType HeapOverflowCheckAdd(const size_t size,
   const size_t increment)
@@ -64,7 +71,11 @@ static inline size_t OverAllocateMemory(const size_t length)
   */
   extent=length;
   if (extent < 131072)
-    for (extent=256; extent < length; extent*=2);
+    {
+      extent=256;
+      while (extent < length)
+        extent*=2;
+    }
   return(extent);
 }

diff --git a/MagickCore/memory_.h b/MagickCore/memory_.h
index 86c5a8f4e..50b4da85e 100644
--- a/MagickCore/memory_.h
+++ b/MagickCore/memory_.h
@@ -19,6 +19,9 @@
 #define MAGICKCORE_MEMORY_H

 #include <errno.h>
+#include <limits.h>
+#include <stddef.h>
+#include <stdint.h>

 #ifdef _WIN64
 #  if !defined(SSIZE_MAX)
@@ -89,8 +92,8 @@ extern MagickExport void
   SetMagickMemoryMethods(AcquireMemoryHandler,ResizeMemoryHandler,
     DestroyMemoryHandler);

-static inline MagickBooleanType HeapOverflowSanityCheck(
-  const size_t count,const size_t quantum)
+static inline MagickBooleanType HeapOverflowSanityCheck(const size_t count,
+  const size_t quantum)
 {
   if ((count == 0) || (quantum == 0))
     return(MagickTrue);
@@ -105,6 +108,8 @@ static inline MagickBooleanType HeapOverflowSanityCheck(
 static inline MagickBooleanType HeapOverflowSanityCheckGetSize(
   const size_t count,const size_t quantum,size_t *const extent)
 {
+  if (extent != NULL)
+    *extent=0;  /* never leave the caller with an uninitialized extent */
   if ((count == 0) || (quantum == 0))
     return(MagickTrue);
   if (count > (MAGICK_SIZE_MAX/quantum))