diff --git a/magick/cache.c b/magick/cache.c
index 8379c66..8eed032 100644
--- a/magick/cache.c
+++ b/magick/cache.c
@@ -49,6 +49,7 @@
 #include "magick/composite-private.h"
 #include "magick/exception.h"
 #include "magick/exception-private.h"
+#include "magick/geometry.h"
 #include "magick/list.h"
 #include "magick/log.h"
 #include "magick/magick.h"
@@ -5009,28 +5010,29 @@
       number_pixels=(MagickSizeType) cache_info->columns*cache_info->rows;
       if ((offset >= 0) && (((MagickSizeType) offset+length) < number_pixels))
         {
-          long
-            x,
-            y;
+          OffsetInfo
+            offset_info;
 
-          x=nexus_info->region.x+nexus_info->region.width;
-          y=nexus_info->region.y+nexus_info->region.height;
-          if ((nexus_info->region.x >= 0) &&
-              (x <= (long) cache_info->columns) &&
-              (nexus_info->region.y >= 0) && (y <= (long) cache_info->rows))
-            if ((nexus_info->region.height == 1UL) ||
-                ((nexus_info->region.x == 0) &&
-                ((nexus_info->region.width % cache_info->columns) == 0)))
-              {
-                /*
-                  Pixels are accessed directly from memory.
-                */
-                nexus_info->pixels=cache_info->pixels+offset;
-                nexus_info->indexes=(IndexPacket *) NULL;
-                if (cache_info->active_index_channel != MagickFalse)
-                  nexus_info->indexes=cache_info->indexes+offset;
-                return(nexus_info->pixels);
-              }
+          offset_info.x=nexus_info->region.x+nexus_info->region.width;
+          offset_info.y=nexus_info->region.y+nexus_info->region.height;
+          if (((nexus_info->region.x >= 0) &&
+               (offset_info.x <= (long) cache_info->columns) &&
+               (nexus_info->region.y >= 0) &&
+               (offset_info.y <= (long) cache_info->rows)) &&
+              ((nexus_info->region.height == 1UL) ||
+               ((nexus_info->region.x == 0) &&
+               ((nexus_info->region.width == cache_info->columns) ||
+                ((nexus_info->region.width % cache_info->columns) == 0)))))
+            {
+              /*
+                Pixels are accessed directly from memory.
+              */
+              nexus_info->pixels=cache_info->pixels+offset;
+              nexus_info->indexes=(IndexPacket *) NULL;
+              if (cache_info->active_index_channel != MagickFalse)
+                nexus_info->indexes=cache_info->indexes+offset;
+              return(nexus_info->pixels);
+            }
         }
     }
   /*