From 42c36c10f5190bdf458c219b6e53c31bf18f1439 Mon Sep 17 00:00:00 2001 From: cristy Date: Sun, 27 Apr 2014 19:57:46 +0000 Subject: [PATCH] --- MagickCore/quantum-export.c | 2 ++ coders/miff.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/MagickCore/quantum-export.c b/MagickCore/quantum-export.c index 0ba781d67..a3bf72b81 100644 --- a/MagickCore/quantum-export.c +++ b/MagickCore/quantum-export.c @@ -190,6 +190,8 @@ static inline unsigned char *PopQuantumPixel(QuantumInfo *quantum_info, if (quantum_bits > quantum_info->state.bits) quantum_bits=quantum_info->state.bits; i-=(ssize_t) quantum_bits; + if (i < 0) + i=0; if (quantum_info->state.bits == 8UL) *pixels='\0'; quantum_info->state.bits-=quantum_bits; diff --git a/coders/miff.c b/coders/miff.c index fd1cce41e..7b37d1eac 100644 --- a/coders/miff.c +++ b/coders/miff.c @@ -1717,18 +1717,22 @@ static unsigned char *PopRunlengthPacket(Image *image,unsigned char *pixels, { if (image->storage_class != DirectClass) { + unsigned int + value; + + value=(unsigned int) ClampToQuantum(pixel->index); switch (image->depth) { case 32: { - *pixels++=(unsigned char) ((size_t) pixel->index >> 24); - *pixels++=(unsigned char) ((size_t) pixel->index >> 16); + *pixels++=(unsigned char) (value >> 24); + *pixels++=(unsigned char) (value >> 16); } case 16: - *pixels++=(unsigned char) ((size_t) pixel->index >> 8); + *pixels++=(unsigned char) (value >> 8); case 8: { - *pixels++=(unsigned char) pixel->index; + *pixels++=(unsigned char) value; break; } default: -- 2.50.1