<?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>12378</bug_id>
          
          <creation_ts>2007-01-23 02:18:26 -0800</creation_ts>
          <short_desc>QString::mid is broken (KWQString.mm)</short_desc>
          <delta_ts>2007-01-24 11:10:09 -0800</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>418.x</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</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="Holger Freyther">zecke</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bradley.morrison</cc>
    
    <cc>darin</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>mjs</cc>
    
    <cc>mrowe</cc>
    
    <cc>rachael</cc>
    
    <cc>yongjun.zhang</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>33143</commentid>
    <comment_count>0</comment_count>
    <who name="Holger Freyther">zecke</who>
    <bug_when>2007-01-23 02:18:26 -0800</bug_when>
    <thetext>QString::mid from KWQ is broken. It refers to index which is not a class member and not a global variable. index is the function from the C library. The address of index is taken and compared to 0. As index is not declared as weak symbol it is very unlikely that this comparsions leads to true.


The following code illustrates the issue:
cat method_test.mm
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;strings.h&gt;

#include &lt;unistd.h&gt;


int main(int argc, char **argv) {
    if( fork == 0 &amp;&amp; index == 0 )
        printf(&quot;Foo Bar\n&quot;);


    return EXIT_SUCCESS;
}

when compiling and executing nothing is printed on the terminal. I have not searched for more occurences of the same pattern (taking an address of a function and comparing it to a value).

Both WebKit418 and the Series60 port are affected</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33130</commentid>
    <comment_count>1</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-01-23 04:46:54 -0800</bug_when>
    <thetext>This was fixed on WebKit ToT (trunk) in r12905 by mjs while porting QString to win32.  (The code is now in WebCore/platform/DeprecatedString.cpp.)

http://trac.webkit.org/projects/webkit/changeset/12905

This bug still exists on the Safari-2-0-branch.  (The code is in WebCore/kwq/KWQString.mm.)  Does this need a Radar bug?

This bug still exists on S60/trunk.  (The code is in WebCore/kwq/KWQString.cpp.)

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33098</commentid>
    <comment_count>2</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-01-23 05:22:22 -0800</bug_when>
    <thetext>This bug was introduced in r3344 when the QString::left(), right() and mid() functions were rewritten.

http://trac.webkit.org/projects/webkit/changeset/3344

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32852</commentid>
    <comment_count>3</comment_count>
      <attachid>12643</attachid>
    <who name="alan">zalan</who>
    <bug_when>2007-01-24 05:03:53 -0800</bug_when>
    <thetext>Created attachment 12643
S60 patch on QString::mid()</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32859</commentid>
    <comment_count>4</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2007-01-24 09:24:01 -0800</bug_when>
    <thetext>(In reply to comment #1)
&gt; This bug still exists on the Safari-2-0-branch.  (The code is in
&gt; WebCore/kwq/KWQString.mm.)  Does this need a Radar bug?

Given that the bug has no known symptom, I don&apos;t think it&apos;s important to fix it for the Safari 2.0 branch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32860</commentid>
    <comment_count>5</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2007-01-24 09:25:11 -0800</bug_when>
    <thetext>This check is a performance optimization for the special case where start is 0 -- that&apos;s another reason I think it&apos;s not urgent to fix for the Safari 2.0 branch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32861</commentid>
    <comment_count>6</comment_count>
      <attachid>12643</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2007-01-24 09:25:57 -0800</bug_when>
    <thetext>Comment on attachment 12643
S60 patch on QString::mid()

Patch looks fine. r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32862</commentid>
    <comment_count>7</comment_count>
    <who name="Bradley Morrison">bradley.morrison</who>
    <bug_when>2007-01-24 09:35:55 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; (From update of attachment 12643 [edit])
&gt; Patch looks fine. r=me
&gt; 

Thanks for the report, patch and the review! Landed in s60 branch (r19077).

Setting to resolved as it&apos;s fixed in ToT and is not required for safari 2.0.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32863</commentid>
    <comment_count>8</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-01-24 09:59:58 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; This check is a performance optimization for the special case where start is 0
&gt; -- that&apos;s another reason I think it&apos;s not urgent to fix for the Safari 2.0
&gt; branch.

The worst case would be if a &quot;false positive&quot; condition occurred and the method returned early with the wrong results.  An analysis of all the code that ends up calling this method would have to be performed, though.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>32868</commentid>
    <comment_count>9</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2007-01-24 11:10:09 -0800</bug_when>
    <thetext>(In reply to comment #8)
&gt; The worst case would be if a &quot;false positive&quot; condition occurred and the method
&gt; returned early with the wrong results.  An analysis of all the code that ends
&gt; up calling this method would have to be performed, though. 

No, that false positive case doesn&apos;t exist. The index symbol can&apos;t be 0.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>12643</attachid>
            <date>2007-01-24 05:03:53 -0800</date>
            <delta_ts>2007-01-24 09:25:57 -0800</delta_ts>
            <desc>S60 patch on QString::mid()</desc>
            <filename>indexToStart.txt</filename>
            <type>text/plain</type>
            <size>1130</size>
            <attacher name="alan">zalan</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nDQo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQotLS0gV2ViQ29yZS9DaGFuZ2VM
b2cgICAocmV2aXNpb24gMTkwNzUpDQorKysgV2ViQ29yZS9DaGFuZ2VMb2cgICAod29ya2luZyBj
b3B5KQ0KQEAgLTEsMyArMSwxMiBAQA0KKzIwMDctMDEtMjQgIGJ1anRhcyAgPHpidWp0YXNAZ21h
aWwuY29tPg0KKw0KKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuDQorICAgICAg
ICBERVNDOiAnaW5kZXgnIHZhcmlhYmxlIGlzIG5vdCBkZWNsYXJlZCwgY2hhbmdlIGl0IHRvICdz
dGFydCcgDQorICAgICAgICBodHRwOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0x
MjM3OA0KKw0KKyAgICAgICAgKiBrd3EvS1dRU3RyaW5nLmNwcDoNCisgICAgICAgIChRU3RyaW5n
OjptaWQpOg0KKw0KIDIwMDctMDEtMjIgIHczbGl1ICA8d2VpLmxpdUBub2tpYS5jb20+DQogDQog
ICAgICAgICBSZXZpZXdlZCBieSBaYWxhbiBCdWp0YXMgPHpidWp0YXNAZ21haWwuY29tPiwgbGFu
ZGVkIGJ5IGJyYWQuDQpJbmRleDogV2ViQ29yZS9rd3EvS1dRU3RyaW5nLmNwcA0KPT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PQ0KLS0tIFdlYkNvcmUva3dxL0tXUVN0cmluZy5jcHAgICAocmV2aXNpb24gMTkwNzUpDQorKysg
V2ViQ29yZS9rd3EvS1dRU3RyaW5nLmNwcCAgICh3b3JraW5nIGNvcHkpDQpAQCAtMTcyNiw3ICsx
NzI2LDcgQEAgUVN0cmluZyBRU3RyaW5nOjptaWQodWludCBzdGFydCwgdWludCBsZQ0KICAgICAg
ICAgaWYoIGxlbiA+IGRhdGEuX2xlbmd0aCAtIHN0YXJ0ICkNCiAgICAgICAgICAgICBsZW4gPSBk
YXRhLl9sZW5ndGggLSBzdGFydDsNCiANCi0gICAgICAgIGlmICggaW5kZXggPT0gMCAmJiBsZW4g
PT0gZGF0YS5fbGVuZ3RoICkNCisgICAgICAgIGlmKCBzdGFydCA9PSAwICYmIGxlbiA9PSBkYXRh
Ll9sZW5ndGggKQ0KICAgICAgICAgICAgIHJldHVybiAqdGhpczsNCiANCiAgICAgICAgIEFTU0VS
VCggc3RhcnQrbGVuPD1kYXRhLl9sZW5ndGggKTsgIC8vIHJhbmdlIGNoZWNrDQo=
</data>
<flag name="review"
          id="4805"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>