<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>15141</bug_id>
          
          <creation_ts>2007-09-04 11:48:12 -0700</creation_ts>
          <short_desc>GIFImageReader can decode incorrectly at different packet boundaries</short_desc>
          <delta_ts>2007-10-14 04:38:02 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Images</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Peter Kasting">pkasting</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>932</commentid>
    <comment_count>0</comment_count>
    <who name="Peter Kasting">pkasting</who>
    <bug_when>2007-09-04 11:48:12 -0700</bug_when>
    <thetext>WebCore/platform/image-decoders/gif/GIFImageReader.cpp (not used by Safari, but used by Cairo/QT) has bugs relating to how it was borrowed from the Mozilla codebase, which provides data to the decoder differently.

In the Mozilla world, the decoder is called with only the new data seen since the last call, so a hold buffer is used to store not-yet-decoded data that should be prepended to the next incoming chunk.  In the WebKit world, the decoder is provided the entire data stream up to the current point every time.  To fit these two together, GIFImageDecoder.cpp contains some wrapper code that lets the reader call back to say &quot;I&apos;ve decoded up to this point&quot;, and then the wrapper will call the reader with only the data from there the next time.

The problem is that this callback isn&apos;t actually used in a couple places where it should be, meaning that depending on where your packet boundaries are, GIFs fail to decode or decode incorrectly.

The true fix to this would be to rewrite the reader and its wrapper to eliminate the hold buffer entirely and be fully aware of the way data is going to be provided.  However, that&apos;s a slightly trickier task than what I propose to do in this bug, which is to at least insert the necessary callback calls so that the decoder always gets data from the right point.  Patch coming shortly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>933</commentid>
    <comment_count>1</comment_count>
      <attachid>16198</attachid>
    <who name="Peter Kasting">pkasting</who>
    <bug_when>2007-09-04 11:56:15 -0700</bug_when>
    <thetext>Created attachment 16198
patch v1

Contains the aforementioned fix, plus one other tiny change: when the GIF reader fails, return failure rather than success, so we stop decoding (as Mozilla does) instead of trying again and again.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57386</commentid>
    <comment_count>2</comment_count>
      <attachid>16198</attachid>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2007-09-29 18:11:55 -0700</bug_when>
    <thetext>Comment on attachment 16198
patch v1

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58484</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2007-10-14 04:38:02 -0700</bug_when>
    <thetext>Landed in r26580.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>16198</attachid>
            <date>2007-09-04 11:56:15 -0700</date>
            <delta_ts>2007-09-29 18:11:55 -0700</delta_ts>
            <desc>patch v1</desc>
            <filename>patch</filename>
            <type>text/plain</type>
            <size>1689</size>
            <attacher name="Peter Kasting">pkasting</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiAyNTM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b3B5KQpAQCAtNDE1LDYgKzQxNSw4IEBAIGJvb2wg
R0lGSW1hZ2VSZWFkZXI6OnJlYWQoY29uc3QgdW5zaWduZWQKICAgICAgIC8vIE5vdCBlbm91Z2gg
aW4gJ2J1ZicgdG8gY29tcGxldGUgY3VycmVudCBibG9jaywgZ2V0IG1vcmUKICAgICAgIGJ5dGVz
X2luX2hvbGQgKz0gbDsKICAgICAgIGJ5dGVzX3RvX2NvbnN1bWUgLT0gbDsKKyAgICAgIGlmIChj
bGllbnRwdHIpCisgICAgICAgIGNsaWVudHB0ci0+ZGVjb2RpbmdIYWx0ZWQoMCk7CiAgICAgICBy
ZXR1cm4gdHJ1ZTsKICAgICB9CiAgICAgLy8gUmVzZXQgaG9sZCBidWZmZXIgY291bnQKQEAgLTky
MSw3ICs5MjMsNyBAQCBib29sIEdJRkltYWdlUmVhZGVyOjpyZWFkKGNvbnN0IHVuc2lnbmVkCiAg
ICAgLy8gSGFuZGxlIGdlbmVyYWwgZXJyb3JzCiAgICAgY2FzZSBnaWZfZXJyb3I6CiAgICAgICAv
LyBuc0dJRkRlY29kZXIyOjpFbmRHSUYoZ3MtPmNsaWVudHB0ciwgZ3MtPmxvb3BfY291bnQpOwot
ICAgICAgcmV0dXJuIHRydWU7CisgICAgICByZXR1cm4gZmFsc2U7CiAKICAgICAvLyBXZSBzaG91
bGRuJ3QgZXZlciBnZXQgaGVyZS4KICAgICBkZWZhdWx0OgpAQCAtOTQ1LDYgKzk0Nyw4IEBAIGJv
b2wgR0lGSW1hZ2VSZWFkZXI6OnJlYWQoY29uc3QgdW5zaWduZWQKICAgICBieXRlc190b19jb25z
dW1lIC09IGxlbjsKICAgfQogCisgIGlmIChjbGllbnRwdHIpCisgICAgY2xpZW50cHRyLT5kZWNv
ZGluZ0hhbHRlZCgwKTsKICAgcmV0dXJuIHRydWU7CiB9CiAK
</data>
<flag name="review"
          id="6807"
          type_id="1"
          status="+"
          setter="mjs"
    />
          </attachment>
      

    </bug>

</bugzilla>