From 1f70b13ac169b522b0b8df59cb82e23fb52801a1 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Thu, 18 Jul 2019 21:50:46 +0200 Subject: [PATCH] Handle negative count. --- coders/bytebuffer-private.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/coders/bytebuffer-private.h b/coders/bytebuffer-private.h index 94eb6ab7e..c70219bc9 100644 --- a/coders/bytebuffer-private.h +++ b/coders/bytebuffer-private.h @@ -52,13 +52,16 @@ static inline int ReadMagickByteBuffer(MagickByteBuffer *buffer) static inline char *GetMagickByteBufferDatum(MagickByteBuffer *buffer) { ssize_t + count, i; i=0; while (buffer->offset < buffer->count) buffer->data[i++]=buffer->data[buffer->offset++]; - buffer->count=ReadBlob(buffer->image,sizeof(buffer->data)-i,buffer->data+i); - buffer->count+=i; + count=ReadBlob(buffer->image,sizeof(buffer->data)-i,buffer->data+i); + buffer->count=i; + if (count > 0) + buffer->count+=count; buffer->offset=0; return((char *) buffer->data); } -- 2.40.0