<?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>146494</bug_id>
          
          <creation_ts>2015-06-30 22:35:17 -0700</creation_ts>
          <short_desc>REGRESSION (185319): Reproducible crash in WebHistoryItem launching FluidApp</short_desc>
          <delta_ts>2022-02-28 04:09:53 -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>WebKit Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac</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>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Brady Eidson">beidson</reporter>
          <assigned_to name="Brady Eidson">beidson</assigned_to>
          <cc>andersca</cc>
    
    <cc>beidson</cc>
    
    <cc>darin</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1105966</commentid>
    <comment_count>0</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2015-06-30 22:35:17 -0700</bug_when>
    <thetext>REGRESSION (185319): Reproducible crash in WebHistoryItem launching FluidApp

Steps to reproduce:
1 - Download FluidApp from http://fluidapp.com
2 - Create an app from a website (I used webkit.org)
3 - Launch that WebApp

Crash:
1   0x1034112e0 WTFCrash
2   0x104dbe7d9 WTF::CrashOnOverflow::crash()
3   0x104dbe7a9 WTF::CrashOnOverflow::overflowed()
4   0x104dbf471 WTF::Vector&lt;WTF::String, 0ul, WTF::CrashOnOverflow, 16ul&gt;::at(unsigned long)
5   0x104e51edd WTF::Vector&lt;WTF::String, 0ul, WTF::CrashOnOverflow, 16ul&gt;::operator[](unsigned long)
6   0x104eb909b -[WebHistoryItem initFromDictionaryRepresentation:]
7   0x104eb0897 -[WebHistoryPrivate loadHistoryGutsFromURL:savedItemsCount:collectDiscardedItemsInto:error:]
8   0x104eb0a8c -[WebHistoryPrivate loadFromURL:collectDiscardedItemsInto:error:]
9   0x104eb17db -[WebHistory loadFromURL:error:]
10  0x100019c11 -[FUHistoryController setUpHistory]
11  0x1000198ca -[FUHistoryController init]
12  0x100019807 +[FUHistoryController instance]
13  0x10000e293 -[FUApplication finishLaunching]
14  0x7fff8b010a21 -[NSApplication run]
15  0x7fff8af8d354 NSApplicationMain
16  0x1000017c4 start

The code in question:
        auto redirectURLsVector = std::make_unique&lt;Vector&lt;String&gt;&gt;();

        for (NSUInteger i = 0; i &lt; size; ++i) {
            id redirectURL = [redirectURLs objectAtIndex:i];
            if (![redirectURL isKindOfClass:[NSString class]])
                continue;

            (*redirectURLsVector)[i] = (NSString *)redirectURL;
        }

We create a Vector of size 0 then immediately reference the first element.

That&apos;s obviously wrong.

In radar as rdar://problem/21598293</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1105967</commentid>
    <comment_count>1</comment_count>
      <attachid>255899</attachid>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2015-06-30 22:38:01 -0700</bug_when>
    <thetext>Created attachment 255899
Patch v1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1105968</commentid>
    <comment_count>2</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2015-06-30 22:39:01 -0700</bug_when>
    <thetext>Was introduced in http://trac.webkit.org/changeset/185319</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1106071</commentid>
    <comment_count>3</comment_count>
      <attachid>255899</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2015-07-01 09:25:15 -0700</bug_when>
    <thetext>Comment on attachment 255899
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=255899&amp;action=review

&gt; Source/WebKit/mac/History/WebHistoryItem.mm:363
&gt;          NSUInteger size = [redirectURLs count];

After making the thing below a modern Objective-C for loop this can be called right in the reserveInitialCapacity call below.

&gt; Source/WebKit/mac/History/WebHistoryItem.mm:365
&gt; +        redirectURLsVector-&gt;reserveCapacity(size);

This should be reserveInitialCapacity.

&gt; Source/WebKit/mac/History/WebHistoryItem.mm:368
&gt;          for (NSUInteger i = 0; i &lt; size; ++i) {
&gt;              id redirectURL = [redirectURLs objectAtIndex:i];

This should be a modern Objective-C for loop:

    for (id redirectURL in redirectURLs) {

&gt; Source/WebKit/mac/History/WebHistoryItem.mm:372
&gt; +            redirectURLsVector-&gt;append((NSString *)redirectURL);

This should be uncheckedAppend.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1106098</commentid>
    <comment_count>4</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2015-07-01 10:14:28 -0700</bug_when>
    <thetext>https://trac.webkit.org/changeset/186179</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>255899</attachid>
            <date>2015-06-30 22:38:01 -0700</date>
            <delta_ts>2022-02-28 04:09:53 -0800</delta_ts>
            <desc>Patch v1</desc>
            <filename>patch</filename>
            <type>text/plain</type>
            <size>1727</size>
            <attacher name="Brady Eidson">beidson</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJLaXQvbWFjL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQv
bWFjL0NoYW5nZUxvZwppbmRleCA5NGI1YzYxLi5lZGQ5NWQ1IDEwMDY0NAotLS0gYS9Tb3VyY2Uv
V2ViS2l0L21hYy9DaGFuZ2VMb2cKKysrIGIvU291cmNlL1dlYktpdC9tYWMvQ2hhbmdlTG9nCkBA
IC0xLDMgKzEsMTQgQE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MzYyLDEzICszNjIsMTQgQEAgLSAoaWQpaW5pdEZyb21EaWN0aW9uYXJ5UmVwcmVzZW50
YXRpb246KE5TRGljdGlvbmFyeSAqKWRpY3QKICAgICBpZiAoTlNBcnJheSAqcmVkaXJlY3RVUkxz
ID0gW2RpY3QgX3dlYmtpdF9hcnJheUZvcktleTpyZWRpcmVjdFVSTHNLZXldKSB7CiAgICAgICAg
IE5TVUludGVnZXIgc2l6ZSA9IFtyZWRpcmVjdFVSTHMgY291bnRdOwogICAgICAgICBhdXRvIHJl
ZGlyZWN0VVJMc1ZlY3RvciA9IHN0ZDo6bWFrZV91bmlxdWU8VmVjdG9yPFN0cmluZz4+KCk7Cisg
ICAgICAgIHJlZGlyZWN0VVJMc1ZlY3Rvci0+cmVzZXJ2ZUNhcGFjaXR5KHNpemUpOwogCiAgICAg
ICAgIGZvciAoTlNVSW50ZWdlciBpID0gMDsgaSA8IHNpemU7ICsraSkgewogICAgICAgICAgICAg
aWQgcmVkaXJlY3RVUkwgPSBbcmVkaXJlY3RVUkxzIG9iamVjdEF0SW5kZXg6aV07CiAgICAgICAg
ICAgICBpZiAoIVtyZWRpcmVjdFVSTCBpc0tpbmRPZkNsYXNzOltOU1N0cmluZyBjbGFzc11dKQog
ICAgICAgICAgICAgICAgIGNvbnRpbnVlOwogCi0gICAgICAgICAgICAoKnJlZGlyZWN0VVJMc1Zl
Y3RvcilbaV0gPSAoTlNTdHJpbmcgKilyZWRpcmVjdFVSTDsKKyAgICAgICAgICAgIHJlZGlyZWN0
VVJMc1ZlY3Rvci0+YXBwZW5kKChOU1N0cmluZyAqKXJlZGlyZWN0VVJMKTsKICAgICAgICAgfQog
CiAgICAgICAgIGNvcmUoX3ByaXZhdGUpLT5zZXRSZWRpcmVjdFVSTHMoV1RGOjptb3ZlKHJlZGly
ZWN0VVJMc1ZlY3RvcikpOwo=
</data>
<flag name="review"
          id="280990"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>