diff --git a/coders/sun.c b/coders/sun.c
index c117e2a..14c1a2d 100644
--- a/coders/sun.c
+++ b/coders/sun.c
@@ -396,7 +396,7 @@
sun_info.length || !sun_info.length)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
number_pixels=(MagickSizeType) image->columns*image->rows;
- if ((sun_info.depth >= 8) &&
+ if ((sun_info.type != RT_ENCODED) && (sun_info.depth >= 8) &&
((number_pixels*((sun_info.depth+7)/8)) > sun_info.length))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
sun_data=(unsigned char *) AcquireQuantumMemory((size_t) sun_info.length,