diff --git a/packages/fcl-image/src/fpreadtiff.pas b/packages/fcl-image/src/fpreadtiff.pas index cfabb0ec41..5bcfe7dbe0 100644 --- a/packages/fcl-image/src/fpreadtiff.pas +++ b/packages/fcl-image/src/fpreadtiff.pas @@ -2098,7 +2098,7 @@ var // read two or three bytes if CurBitLength+SrcPosBit>16 then begin // read from three bytes - if SrcPos+3>Count then Error('LZW stream overrun'); + if SrcPos+3>=Count then Error('LZW stream overrun'); v:=PByte(Buffer)[SrcPos]; inc(SrcPos); v:=(v shl 8)+PByte(Buffer)[SrcPos]; @@ -2107,7 +2107,7 @@ var v:=v shr (24-CurBitLength-SrcPosBit); end else begin // read from two bytes - if SrcPos+2>Count then Error('LZW stream overrun'); + if SrcPos+2>=Count then Error('LZW stream overrun'); v:=PByte(Buffer)[SrcPos]; inc(SrcPos); v:=(v shl 8)+PByte(Buffer)[SrcPos];