Menu

#32 Crash while gif loading

Current version
closed
nobody
gif (1)
5
2016-07-16
2016-05-08
Anonymous
No

Error in BGRAGifFormat while loading attached file. "RunError(204)". Application crashed. LazPaint also crash while loading this file. Other viewers show this file correctly. I can give more gif-files that do this crash.
Sorry for bad english.

1 Attachments

Discussion

  • Yuri

    Yuri - 2016-05-09

    Solution found!
    GIFCodeTableSize increased from 4096 to 32768. Line 104 in BGRAGifFormat.pas. Works fine.
    Thank you all for a wonderful project :-)

     
  • circular

    circular - 2016-05-10

    Thank you! I have applied the change (32768 when loading, but still 4096 when writing to maximize compatibility)

     
  • circular

    circular - 2016-05-10
    • status: open --> pending
     
  • Yuri

    Yuri - 2016-05-11

    I found a way is better.
    The data from the table with an index greater than 4096 are not used. You just need to add a check for overflow. That is now AddStr2Tab function (line 242) will record and further the index 4096, as variable stridx not limited. To avoid recording in a memory cell outside the table (which leads to a crash), I propose to add a function AddStr2Tab first line this condition:

    if stridx >= GIFCodeTableSize then exit;
    

    Works good. A GIFCodeTableSize size in 4096 - it is right, because it is no longer necessary.
    The result AddStr2Tab:

      procedure AddStr2Tab(prefix: Pstr; suffix: longint);
      begin
        if stridx >= GIFCodeTableSize then exit;
        strtab^[stridx].prefix := prefix;
        strtab^[stridx].suffix := suffix;
        Inc(stridx);
        case stridx of
          0..1: codelen      := 1;
          2..3: codelen      := 2;
          4..7: codelen      := 3;
          8..15: codelen     := 4;
          16..31: codelen    := 5;
          32..63: codelen    := 6;
          64..127: codelen   := 7;
          128..255: codelen  := 8;
          256..511: codelen  := 9;
          512..1023: codelen := 10;
          1024..2047: codelen := 11;
          2048..4096: codelen := 12;
        end;
        codemask := (1 shl codelen) - 1;
      end;
    
     
  • circular

    circular - 2016-05-11

    Indeed, it works fine. I have applied this on SVN.

     
  • Yuri

    Yuri - 2016-05-11

    I am happy to contribute to this wonderful project. :-)

     
  • circular

    circular - 2016-07-16
    • status: pending --> closed
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB