<?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>182473</bug_id>
          
          <creation_ts>2018-02-04 21:11:50 -0800</creation_ts>
          <short_desc>Crash caused by Integer Overflow</short_desc>
          <delta_ts>2018-03-30 07:49:56 -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>JavaScriptCore</component>
          <version>WebKit Local Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>183894</dup_id>
          
          <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>sunlili</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>rmorisset</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1396218</commentid>
    <comment_count>0</comment_count>
    <who name="">sunlili</who>
    <bug_when>2018-02-04 21:11:50 -0800</bug_when>
    <thetext>Hi,

    Following code will cause JavaSciptCore crash.
    Run in webkitgtk-2.19.6. Some older versions(2.18.5) will crash too.

Code:
var ch = String.prototype.repeat.call(&quot;2&quot;, 1&lt;&lt;30);
let identi_arr={
    &quot;ch&quot;:ch,
};
print(&quot;ch generated&quot;)
JSON.stringify(identi_arr);
print(&quot;json finish&quot;)

Output:
ch generated
1   0x7f0e85e34841 WTFCrash
2   0x46765e WTF::CrashOnOverflow::hasOverflowed() const
3   0x467655 WTF::CrashOnOverflow::crash()
4   0x7f0e85028210 JSC::CompleteSubspace* JSC::JSCell::subspaceFor&lt;JSC::JSSet&gt;(JSC::VM&amp;)
5   0x7f0e85e8d11a
6   0x7f0e85e8cc2d
7   0x7f0e85e8c8f3 WTF::StringBuilder::appendQuotedJSONString(WTF::String const&amp;)
8   0x7f0e85b06a94 JSC::Stringifier::appendStringifiedValue(WTF::StringBuilder&amp;, JSC::JSValue, JSC::Stringifier::Holder const&amp;, JSC::PropertyNameForFunctionCall const&amp;)
9   0x7f0e85b077ce JSC::Stringifier::Holder::appendNextProperty(JSC::Stringifier&amp;, WTF::StringBuilder&amp;)
10  0x7f0e85b06dee JSC::Stringifier::appendStringifiedValue(WTF::StringBuilder&amp;, JSC::JSValue, JSC::Stringifier::Holder const&amp;, JSC::PropertyNameForFunctionCall const&amp;)
11  0x7f0e85b063d5 JSC::Stringifier::stringify(JSC::JSValue)
12  0x7f0e85b091fa JSC::JSONProtoFuncStringify(JSC::ExecState*)
13  0x7f0e3f3ff178
Segmentation fault (core dumped)

Reason: 
The ch string is too large, when calculate the maximumCapacityRequired for it, an Integer Overflow be detected in StringBuilder::appendQuotedJSONString(const String&amp; string).

BT group
2018/2/5</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1410595</commentid>
    <comment_count>1</comment_count>
    <who name="Robin Morisset">rmorisset</who>
    <bug_when>2018-03-30 07:49:56 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 183894 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>