View Issue Details

IDProjectCategoryView StatusLast Update
0034919FPCPackagespublic2019-02-21 21:07
Reporterzaxxon Assigned ToMarco van de Voort  
Status resolvedResolutionfixed 
Product Version3.0.4 
Fixed in Version3.3.1 
Summary0034919: Gif reader in FPC hangs when trying to read the attached gif file
DescriptionWhen trying to load the gif file "linux.gif", the gif reader simply hangs.
Steps To ReproduceSimply drop a TImage in a form in Lazarus and try to load the attached file. This will cause the entire Lazarus to hang.
TagsNo tags attached.
Fixed in Revision40995
Attached Files


related to 0035134 closedMichael Van Canneyt fpreadgif: r40995 broke paletted GIF reading 



2019-01-21 14:11


linux.gif (575 bytes)   
linux.gif (575 bytes)   

Bart Broersma

2019-01-21 22:23

reporter   ~0113554

The Gif is invalid?

C:\......\linux.gif : Decode error !

Invalid or unsupported GIF file.


2019-01-22 09:05

reporter   ~0113564

The gif can be open in other programs. I think it's greyscale.

Small changes in FPReadGif prevents it from ending up in infinite loops.

in Internal read :

    // skip extensions
    until (Introducer = $2C) or (Introducer = $3B) or (Stream.Position>=Stream.Size);

    if Stream.Position>=Stream.Size then Exit;

and in Readscanline on two locations:

    Repeat, 1);
      if B > 0 then
         Stream.ReadBuffer(SourcePtr^, B);
    until (B = 0) or (Stream.Position>=Stream.Size);

    if Stream.Position>Stream.Size then begin

At least this prevent the gif reader to end up in infinite loop. When trying to load unsupported gifs.

Thaddy de Koning

2019-01-22 09:31

reporter   ~0113566

Last edited: 2019-01-22 09:34

View 2 revisions

The gif is invalid. Even Chromium will not accept it.
There are multiple ways to check the validity already, including brute force exception handling. This is a non-issue.


2019-01-22 09:55

reporter   ~0113568

Internet explorer opened it. I think even if the gif file is invalid the reader shouldn't end up in an infinite loop. I should be protected from that.

Thaddy de Koning

2019-01-22 11:08

reporter   ~0113574

You are a programmer, not an end user?


2019-01-22 12:00

reporter   ~0113577

Anyway I used the changes presented in the post above and that solved it for me, so i'm happy. But i still think some changes at least should be made to the existing code. To prevent infinite loops.

Marco van de Voort

2019-01-22 16:11

manager   ~0113584

Applied, thanks.

Thaddy, please keep the noise down.

Issue History

Date Modified Username Field Change
2019-01-21 14:11 zaxxon New Issue
2019-01-21 14:11 zaxxon File Added: linux.gif
2019-01-21 22:23 Bart Broersma Note Added: 0113554
2019-01-22 09:05 zaxxon Note Added: 0113564
2019-01-22 09:31 Thaddy de Koning Note Added: 0113566
2019-01-22 09:34 Thaddy de Koning Note Edited: 0113566 View Revisions
2019-01-22 09:55 zaxxon Note Added: 0113568
2019-01-22 11:08 Thaddy de Koning Note Added: 0113574
2019-01-22 12:00 zaxxon Note Added: 0113577
2019-01-22 16:11 Marco van de Voort Fixed in Revision => 40995
2019-01-22 16:11 Marco van de Voort Note Added: 0113584
2019-01-22 16:11 Marco van de Voort Status new => resolved
2019-01-22 16:11 Marco van de Voort Fixed in Version => 3.3.1
2019-01-22 16:11 Marco van de Voort Resolution open => fixed
2019-01-22 16:11 Marco van de Voort Assigned To => Marco van de Voort
2019-02-21 21:07 Marco van de Voort Relationship added related to 0035134