https://github.com/ImageMagick/ImageMagick/issues/131
diff --git a/coders/mat.c b/coders/mat.c
index b5a3f1f..93a9d87 100644
--- a/coders/mat.c
+++ b/coders/mat.c
@@ -864,7 +864,7 @@
return(DestroyImageList(image));
/* ----- Load raster data ----- */
- BImgBuff = (unsigned char *) AcquireQuantumMemory((size_t) (ldblk),sizeof(unsigned char)); /* Ldblk was set in the check phase */
+ BImgBuff = (unsigned char *) AcquireQuantumMemory((size_t) (ldblk),sizeof(double)); /* Ldblk was set in the check phase */
if (BImgBuff == NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");