diff --git a/MagickCore/quantum.c b/MagickCore/quantum.c
index 36897c4..e84c428 100644
--- a/MagickCore/quantum.c
+++ b/MagickCore/quantum.c
@@ -128,9 +128,9 @@
   if (image == (const Image *) NULL)
     return(quantum_info);
   status=SetQuantumDepth(image,quantum_info,image->depth);
+  quantum_info->endian=image->endian;
   if (status == MagickFalse)
     quantum_info=DestroyQuantumInfo(quantum_info);
-  quantum_info->endian=image->endian;
   return(quantum_info);
 }
 
@@ -678,8 +678,8 @@
     }
   if (quantum_info->pixels != (unsigned char **) NULL)
     DestroyQuantumPixels(quantum_info);
-  status=AcquireQuantumPixels(quantum_info,(6+quantum_info->pad)*image->columns*
-    ((quantum_info->depth+7)/8));  /* allow for CMYKA + RLE byte + pad */
+  status=AcquireQuantumPixels(quantum_info,(MaxPixelChannels+quantum_info->pad)*
+    image->columns*((quantum_info->depth+7)/8));
   return(status);
 }