From e1e032d08396f398a1b851077879cdae024f0f95 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 29 May 2020 11:09:22 +0200 Subject: Gif decoder: avoid undefined values in enum The gif standard allocates 3 bits for the disposal method, but values 4-7 are unused. Change-Id: I0f70b3f87b4cd8e98140c3da476702a22ebe93a9 Reviewed-by: Paul Olav Tvete (cherry picked from commit 30571068b203a9d950030b31ee84f08f2f6fc04d) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/imageformats/gif/qgifhandler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index 1aef1a24d2..8d82bb15ca 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -629,7 +629,8 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, count++; if (count==hold[0]+1) { disposePrevious(image); - disposal=Disposal((hold[1]>>2)&0x7); + uint dBits = (hold[1] >> 2) & 0x7; + disposal = (dBits <= RestoreImage) ? Disposal(dBits) : NoDisposal; //UNUSED: waitforuser=!!((hold[1]>>1)&0x1); int delay=count>3 ? LM(hold[2], hold[3]) : 1; // IE and mozilla use a minimum delay of 10. With the minimum delay of 10 -- cgit v1.2.3