<?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>25659</bug_id>
          
          <creation_ts>2009-05-08 21:08:02 -0700</creation_ts>
          <short_desc>Calling frameCount() from BitmapImage::destroyDecodedDataIfNecessary() can cause GIF decoding</short_desc>
          <delta_ts>2009-05-28 10:29:31 -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>528+ (Nightly build)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.5</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="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Peter Kasting">pkasting</assigned_to>
          <cc>pkasting</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>120502</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2009-05-08 21:08:02 -0700</bug_when>
    <thetext>I noticed a stack where, during destruction of an HTMLImageElement, we can actually do some GIF decoding because we&apos;re trying to get frameCount():


  15 WebCore  112.00 Kb     WebCore::Document::removedLastRef() /Volumes/WebKit/WebKit.git/WebCore/dom/Document.cpp:413
  14 WebCore  112.00 Kb     WebCore::ContainerNode::removeAllChildren() /Volumes/WebKit/WebKit.git/WebCore/dom/ContainerNode.cpp:56
  13 WebCore  112.00 Kb     void WebCore::removeAllChildrenInContainer&lt;WebCore::Node, WebCore::ContainerNode&gt;(WebCore::ContainerNode*) /Volumes/WebKit/WebKit.git/WebCore/dom/ContainerNodeAlgorithms.h:51
  12 WebCore  112.00 Kb     WebCore::HTMLImageElement::~HTMLImageElement()
  11 WebCore  112.00 Kb     WebCore::HTMLImageLoader::~HTMLImageLoader()
  10 WebCore  112.00 Kb     WebCore::ImageLoader::~ImageLoader()
   9 WebCore  112.00 Kb     WebCore::CachedResource::removeClient(WebCore::CachedResourceClient*) /Volumes/WebKit/WebKit.git/WebCore/loader/CachedResource.cpp:166
   8 WebCore  112.00 Kb     WebCore::CachedImage::allClientsRemoved() /Volumes/WebKit/WebKit.git/WebCore/loader/CachedImage.cpp:112
   7 WebCore  112.00 Kb     WebCore::BitmapImage::resetAnimation() /Volumes/WebKit/WebKit.git/WebCore/platform/graphics/BitmapImage.cpp:378
   6 WebCore  112.00 Kb     WebCore::BitmapImage::destroyDecodedDataIfNecessary(bool) /Volumes/WebKit/WebKit.git/WebCore/platform/graphics/BitmapImage.cpp:98
   5 WebCore  112.00 Kb     WebCore::BitmapImage::frameCount() /Volumes/WebKit/WebKit.git/WebCore/platform/graphics/BitmapImage.cpp:187
   4 WebCore  112.00 Kb     WebCore::ImageSource::frameCount() const /Volumes/WebKit/WebKit.git/WebCore/platform/graphics/cg/ImageSourceCG.cpp:174
   3 ImageIO  112.00 Kb     CGImageSourceGetCount
   2 ImageIO  112.00 Kb     gifPluginImageCount
   1 libGIF.dylib  112.00 Kb     _cg_DGifOpen
   0 libSystem.B.dylib  112.00 Kb     malloc</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123343</commentid>
    <comment_count>1</comment_count>
    <who name="Peter Kasting">pkasting</who>
    <bug_when>2009-05-27 17:25:23 -0700</bug_when>
    <thetext>I think destroyDecodedData() should be checking m_frames.size() instead of frameCount().  m_frames.size() represents how many frames we have potentially decoded (though some or all may currently be empty), while frameCount() is the size of the whole image.  We never really care how big the image theoretically is, just how much data we could actually have lying around at the moment.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123352</commentid>
    <comment_count>2</comment_count>
      <attachid>30726</attachid>
    <who name="Peter Kasting">pkasting</who>
    <bug_when>2009-05-27 18:19:18 -0700</bug_when>
    <thetext>Created attachment 30726
patch v1

This should fix it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123433</commentid>
    <comment_count>3</comment_count>
    <who name="Peter Kasting">pkasting</who>
    <bug_when>2009-05-28 10:29:31 -0700</bug_when>
    <thetext>Fixed in r44237.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>30726</attachid>
            <date>2009-05-27 18:19:18 -0700</date>
            <delta_ts>2009-05-27 20:45:11 -0700</delta_ts>
            <desc>patch v1</desc>
            <filename>patch</filename>
            <type>text/plain</type>
            <size>1293</size>
            <attacher name="Peter Kasting">pkasting</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiA0NDIxMikKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMTQgQEAKKzIwMDktMDUtMjcgIFBldGVyIEthc3RpbmcgIDxwa2FzdGluZ0Bnb29n
bGUuY29tPgorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAg
IGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0yNTY1OQorICAgICAgICBB
dm9pZCBjYWxsaW5nIGZyYW1lQ291bnQoKSB1bm5lY2Vzc2FyaWx5ICh3aGljaCBjb3VsZCBsZWFk
IHRvIGV4dHJhCisgICAgICAgIEdJRiBkZWNvZG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WF0aW9uQ3V0b2ZmKQogICAgICAg
ICBkZXN0cm95RGVjb2RlZERhdGEoZGVzdHJveUFsbCk7CiB9CiAK
</data>
<flag name="review"
          id="15576"
          type_id="1"
          status="+"
          setter="simon.fraser"
    />
          </attachment>
      

    </bug>

</bugzilla>