<?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>30502</bug_id>
          
          <creation_ts>2009-10-18 22:48:34 -0700</creation_ts>
          <short_desc>Dereference of uninitialized variable</short_desc>
          <delta_ts>2009-10-19 10:36:11 -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>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</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>P3</priority>
          <bug_severity>Minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kent Tamura">tkent</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>commit-queue</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>155569</commentid>
    <comment_count>0</comment_count>
    <who name="Kent Tamura">tkent</who>
    <bug_when>2009-10-18 22:48:34 -0700</bug_when>
    <thetext>WebCore/dom/Element.cpp setBooleanAttribute();

        ExceptionCode ex;
        removeAttribute(name, ex);

removeAttribute():
  void Element::removeAttribute(const QualifiedName&amp; name, ExceptionCode&amp; ec)
  {
      if (namedAttrMap) {
          namedAttrMap-&gt;removeNamedItem(name, ec);
          if (ec == NOT_FOUND_ERR)
              ec = 0;
      }
  }

removeNamedItem() doesn&apos;t set any value to ec if the specified attribute exists.  So, if removeAttribute() is called by setBooleanAttribute(), uninitialized ec can be referred at &quot;if (ec == NOT_FOUND_ERR)&quot;.

Note: This never makes a real bug because ex in setBooleanAttribute() is not used after removeAttribute() call.
Valgrind complaints about this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155578</commentid>
    <comment_count>1</comment_count>
      <attachid>41398</attachid>
    <who name="Kent Tamura">tkent</who>
    <bug_when>2009-10-18 23:11:45 -0700</bug_when>
    <thetext>Created attachment 41398
Proposed patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155589</commentid>
    <comment_count>2</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2009-10-18 23:52:14 -0700</bug_when>
    <thetext>Wouldn’t it make more sense to initialize the variable at the level that it matters?  setBooleanAttribute doesn’t care about the exception code so there’s no need for it to do anything with it.  After your change the code in removeAttribute will still do the wrong thing if called by another caller.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155590</commentid>
    <comment_count>3</comment_count>
    <who name="Kent Tamura">tkent</who>
    <bug_when>2009-10-18 23:55:30 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; Wouldn’t it make more sense to initialize the variable at the level that it
&gt; matters?  setBooleanAttribute doesn’t care about the exception code so there’s
&gt; no need for it to do anything with it.  After your change the code in
&gt; removeAttribute will still do the wrong thing if called by another caller.

I think our convention for ExceptionCode is &quot;initialize it with 0 when it is declared.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155594</commentid>
    <comment_count>4</comment_count>
    <who name="Kent Tamura">tkent</who>
    <bug_when>2009-10-19 00:00:56 -0700</bug_when>
    <thetext>&gt; I think our convention for ExceptionCode is &quot;initialize it with 0 when it is
&gt; declared.&quot;

So, if removeAttribute() set 0 before removenamedItem() and other callers initialize ec with 0, we would have redundant initialization.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155596</commentid>
    <comment_count>5</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2009-10-19 00:14:54 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; (In reply to comment #2)
&gt; &gt; Wouldn’t it make more sense to initialize the variable at the level that it
&gt; &gt; matters?  setBooleanAttribute doesn’t care about the exception code so there’s
&gt; &gt; no need for it to do anything with it.  After your change the code in
&gt; &gt; removeAttribute will still do the wrong thing if called by another caller.
&gt; 
&gt; I think our convention for ExceptionCode is &quot;initialize it with 0 when it is
&gt; declared.”

A quick grep in WebCore for “ExceptionCode ec;” shows that is not the case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155601</commentid>
    <comment_count>6</comment_count>
      <attachid>41398</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2009-10-19 00:20:04 -0700</bug_when>
    <thetext>Comment on attachment 41398
Proposed patch

As Mark said - if a caller doesn&apos;t plan to look at ExceptionCode, it can pass an uninitialized value. See bug 21939 for more detailed discussion of the current policy (especially comments 3 and 12 there).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155604</commentid>
    <comment_count>7</comment_count>
      <attachid>41400</attachid>
    <who name="Kent Tamura">tkent</who>
    <bug_when>2009-10-19 00:30:01 -0700</bug_when>
    <thetext>Created attachment 41400
Proposed patch (rev.2)

ok, I follow it.

Updated the patch so that removeAttribute() initializes ec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155684</commentid>
    <comment_count>8</comment_count>
      <attachid>41400</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2009-10-19 08:14:34 -0700</bug_when>
    <thetext>Comment on attachment 41400
Proposed patch (rev.2)

r=me

It may make sense to add a comment explaining that this assignment is only needed to please tools like valgrind - since it&apos;s useless otherwise, people will be tempted to remove it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155702</commentid>
    <comment_count>9</comment_count>
      <attachid>41400</attachid>
    <who name="Yong Li">yong.li.webkit</who>
    <bug_when>2009-10-19 08:49:35 -0700</bug_when>
    <thetext>Comment on attachment 41400
Proposed patch (rev.2)

Let commit bot land it</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155747</commentid>
    <comment_count>10</comment_count>
      <attachid>41400</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2009-10-19 09:42:44 -0700</bug_when>
    <thetext>Comment on attachment 41400
Proposed patch (rev.2)

Rejecting patch 41400 from commit-queue.

Failed to run &quot;[&apos;WebKitTools/Scripts/run-webkit-tests&apos;, &apos;--no-launch-safari&apos;, &apos;--quiet&apos;, &apos;--exit-after-n-failures=1&apos;]&quot; exit_code: 1
Running build-dumprendertree
Running tests from /Users/eseidel/Projects/CommitQueue/LayoutTests
Testing 11468 test cases.
http/tests/navigation/postredirect-reload.html -&gt; crashed

Exiting early after 1 failures. 8689 tests run.
390.95s total testing time

8688 test cases (99%) succeeded
1 test case (&lt;1%) crashed
5 test cases (&lt;1%) had stderr output</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155759</commentid>
    <comment_count>11</comment_count>
      <attachid>41400</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-10-19 10:11:57 -0700</bug_when>
    <thetext>Comment on attachment 41400
Proposed patch (rev.2)

That crash looks unrelated to your patch.  I&apos;ve filed bug 30519.  Adding this back to the commit-queue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155772</commentid>
    <comment_count>12</comment_count>
      <attachid>41400</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2009-10-19 10:36:06 -0700</bug_when>
    <thetext>Comment on attachment 41400
Proposed patch (rev.2)

Clearing flags on attachment: 41400

Committed r49792: &lt;http://trac.webkit.org/changeset/49792&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>155773</commentid>
    <comment_count>13</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2009-10-19 10:36:11 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>41398</attachid>
            <date>2009-10-18 23:11:45 -0700</date>
            <delta_ts>2009-10-19 00:30:01 -0700</delta_ts>
            <desc>Proposed patch</desc>
            <filename>0001-uninitialized-variable.patch</filename>
            <type>text/plain</type>
            <size>1389</size>
            <attacher name="Kent Tamura">tkent</attacher>
            
              <data encoding="base64">RnJvbSA2Y2VjM2NmOGJiODg3ZTBiZWFjNWEzOGVlZGQ4NDMwZmM3YzYxM2ExIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBLZW50IFRhbXVyYSA8dGtlbnRAY2hyb21pdW0ub3JnPgpEYXRl
OiBNb24sIDE5IE9jdCAyMDA5IDE1OjA4OjQwICswOTAwClN1YmplY3Q6IFtQQVRDSF0gdW5pbml0
aWFsaXplZC12YXJpYWJsZQoKLS0tCiBXZWJDb3JlL0NoYW5nZUxvZyAgICAgICB8ICAgMTEgKysr
KysrKysrKysKIFdlYkNvcmUvZG9tL0VsZW1lbnQuY3BwIHwgICAgNCArKy0tCiAyIGZpbGVzIGNo
YW5nZWQsIDEzIGluc2VydGlvbnMoKyksIDIgZGVsZXRpb25zKC0pCgpkaWZmIC0tZ2l0IGEvV2Vi
Q29yZS9DaGFuZ2VMb2cgYi9XZWJDb3JlL0NoYW5nZUxvZwppbmRleCAwMjdlOWFhLi40YzIyMjgz
IDEwMDY0NAotLS0gYS9XZWJDb3JlL0NoYW5nZUxvZworKysgYi9XZWJDb3JlL0NoYW5nZUxvZwpA
QCAtMSwzICsxLDE0IEBACisyMDA5LTEwLTE4ICBLZW50IFRhbXVyYSAgPHRrZW50QGNocm9taXVt
Lm9yZz4KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBG
aXggdW5pbml0aWFsaXplZCB2YXJpYWJsZSByZWZlcmVuY2UgaW4gRWxlbWVudDo6cmVtb3ZlQXR0
cmlidXRlKCkKKyAgICAgICAgY2FsbGVkIGJ5IHNldEJvb2xlYW5BdHRyaWJ1dGUoKS4KKyAgICAg
ICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTMwNTAyCisKKyAgICAg
ICAgKiBkb20vRWxlbWVudC5jcHA6CisgICAgICAgIChXZWJDb3JlOjpFbGVtZW50OjpzZXRCb29s
ZWFuQXR0cmlidXRlKToKKwogMjAwOS0xMC0xOCAgS2V2aW4gT2xsaXZpZXIgIDxrZXZpbm9AdGhl
b2xsaXZpZXJzLmNvbT4KIAogICAgICAgICBDVVJMIGJ1aWxkIGZpeCwgdXNlIHByb3BlciBoZWFk
ZXIgbmFtZS4KZGlmZiAtLWdpdCBhL1dlYkNvcmUvZG9tL0VsZW1lbnQuY3BwIGIvV2ViQ29yZS9k
b20vRWxlbWVudC5jcHAKaW5kZXggNTBmZjAzMy4uZjcxZjVmOSAxMDA2NDQKLS0tIGEvV2ViQ29y
ZS9kb20vRWxlbWVudC5jcHAKKysrIGIvV2ViQ29yZS9kb20vRWxlbWVudC5jcHAKQEAgLTE0MCw4
ICsxNDAsOCBAQCB2b2lkIEVsZW1lbnQ6OnNldEJvb2xlYW5BdHRyaWJ1dGUoY29uc3QgUXVhbGlm
aWVkTmFtZSYgbmFtZSwgYm9vbCBiKQogICAgIGlmIChiKQogICAgICAgICBzZXRBdHRyaWJ1dGUo
bmFtZSwgbmFtZS5sb2NhbE5hbWUoKSk7CiAgICAgZWxzZSB7Ci0gICAgICAgIEV4Y2VwdGlvbkNv
ZGUgZXg7Ci0gICAgICAgIHJlbW92ZUF0dHJpYnV0ZShuYW1lLCBleCk7CisgICAgICAgIEV4Y2Vw
dGlvbkNvZGUgZWMgPSAwOworICAgICAgICByZW1vdmVBdHRyaWJ1dGUobmFtZSwgZWMpOwogICAg
IH0KIH0KIAotLSAKMS42LjMuMwoK
</data>
<flag name="review"
          id="22771"
          type_id="1"
          status="-"
          setter="ap"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>41400</attachid>
            <date>2009-10-19 00:30:01 -0700</date>
            <delta_ts>2009-10-19 10:36:06 -0700</delta_ts>
            <desc>Proposed patch (rev.2)</desc>
            <filename>0001-uninitialized-variable-2.patch</filename>
            <type>text/plain</type>
            <size>1346</size>
            <attacher name="Kent Tamura">tkent</attacher>
            
              <data encoding="base64">RnJvbSA4MWI3OTUxZTg5NDMwNWFjMDcxZDQwZDhlOTg4YjEwNDE2N2QwZDM3IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBLZW50IFRhbXVyYSA8dGtlbnRAY2hyb21pdW0ub3JnPgpEYXRl
OiBNb24sIDE5IE9jdCAyMDA5IDE1OjA4OjQwICswOTAwClN1YmplY3Q6IFtQQVRDSF0gdW5pbml0
aWFsaXplZC12YXJpYWJsZS0yCgotLS0KIFdlYkNvcmUvQ2hhbmdlTG9nICAgICAgIHwgICAxMCAr
KysrKysrKysrCiBXZWJDb3JlL2RvbS9FbGVtZW50LmNwcCB8ICAgIDEgKwogMiBmaWxlcyBjaGFu
Z2VkLCAxMSBpbnNlcnRpb25zKCspLCAwIGRlbGV0aW9ucygtKQoKZGlmZiAtLWdpdCBhL1dlYkNv
cmUvQ2hhbmdlTG9nIGIvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggMDI3ZTlhYS4uOWRmNGQwOSAx
MDA2NDQKLS0tIGEvV2ViQ29yZS9DaGFuZ2VMb2cKKysrIGIvV2ViQ29yZS9DaGFuZ2VMb2cKQEAg
LTEsMyArMSwxMyBAQAorMjAwOS0xMC0xOCAgS2VudCBUYW11cmEgIDx0a2VudEBjaHJvbWl1bS5v
cmc+CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAgICAgRml4
IHVuaW5pdGlhbGl6ZWQgdmFyaWFibGUgcmVmZXJlbmNlIGluIEVsZW1lbnQ6OnJlbW92ZUF0dHJp
YnV0ZSgpLgorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Z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