<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[209874] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/209874">209874</a></dd>
<dt>Author</dt> <dd>jfbastien@apple.com</dd>
<dt>Date</dt> <dd>2016-12-15 14:08:38 -0800 (Thu, 15 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>JSTests:
WebAssembly API: improve data section errors
https://bugs.webkit.org/show_bug.cgi?id=165733

Reviewed by Keith Miller.

* wasm/js-api/element-data.js: Added.
(ElementBeforeData.set const):
(ElementBeforeData): check the order of initialization, which is observable on failure
* wasm/js-api/test_Data.js:
(DataSectionWithoutMemory):
(DataSectionOffTheEnd): Deleted.
(DataSectionPartlyOffTheEnd): Deleted.
(DataSectionEmptyOffTheEnd): Deleted.
(DataSectionSeenByStart): Deleted.

Source/JavaScriptCore:
WebAssembly API: improve data section errors, initialize after Element
https://bugs.webkit.org/show_bug.cgi?id=165733

Reviewed by Keith Miller.

* wasm/WasmModuleParser.cpp:
(JSC::Wasm::ModuleParser::parseData): Data section without Memory section or import is a validation error
* wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::dataSegmentFail):
(JSC::WebAssemblyModuleRecord::evaluate): tighten checks (though the spec isn't fully baked), and move after Element initialization</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkJSTestsChangeLog">trunk/JSTests/ChangeLog</a></li>
<li><a href="#trunkJSTestswasmjsapitest_Datajs">trunk/JSTests/wasm/js-api/test_Data.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmWasmModuleParsercpp">trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorewasmjsWebAssemblyModuleRecordcpp">trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkJSTestswasmjsapielementdatajs">trunk/JSTests/wasm/js-api/element-data.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkJSTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/ChangeLog (209873 => 209874)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/ChangeLog        2016-12-15 22:08:26 UTC (rev 209873)
+++ trunk/JSTests/ChangeLog        2016-12-15 22:08:38 UTC (rev 209874)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-12-15  JF Bastien  &lt;jfbastien@apple.com&gt;
+
+        WebAssembly API: improve data section errors
+        https://bugs.webkit.org/show_bug.cgi?id=165733
+
+        Reviewed by Keith Miller.
+
+        * wasm/js-api/element-data.js: Added.
+        (ElementBeforeData.set const):
+        (ElementBeforeData): check the order of initialization, which is observable on failure
+        * wasm/js-api/test_Data.js:
+        (DataSectionWithoutMemory):
+        (DataSectionOffTheEnd): Deleted.
+        (DataSectionPartlyOffTheEnd): Deleted.
+        (DataSectionEmptyOffTheEnd): Deleted.
+        (DataSectionSeenByStart): Deleted.
+
</ins><span class="cx"> 2016-12-15  Keith Miller  &lt;keith_miller@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix 64-bit shift family Wasm opcodes
</span></span></pre></div>
<a id="trunkJSTestswasmjsapielementdatajs"></a>
<div class="addfile"><h4>Added: trunk/JSTests/wasm/js-api/element-data.js (0 => 209874)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/js-api/element-data.js                                (rev 0)
+++ trunk/JSTests/wasm/js-api/element-data.js        2016-12-15 22:08:38 UTC (rev 209874)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+import Builder from '../Builder.js';
+import * as assert from '../assert.js';
+
+const memSizeInPages = 1;
+const pageSizeInBytes = 64 * 1024;
+const memoryDescription = { initial: memSizeInPages, maximum: memSizeInPages };
+
+(function ElementBeforeData() {
+    const builder = (new Builder())
+        .Type().End()
+        .Import()
+            .Memory(&quot;imp&quot;, &quot;memory&quot;, memoryDescription)
+            .Table(&quot;imp&quot;, &quot;table&quot;, {element: &quot;anyfunc&quot;, initial: 19}) // unspecified maximum.
+        .End()
+        .Function().End()
+        .Element()
+            .Element({offset: 19, functionIndices: [0, 0, 0, 0, 0]})
+        .End()
+        .Code()
+            .Function(&quot;foo&quot;, {params: [&quot;i32&quot;], ret: &quot;i32&quot;})
+                .GetLocal(0)
+                .I32Const(42)
+                .I32Add()
+                .Return()
+            .End()
+        .End()
+        .Data()
+          .Segment([0xde, 0xad, 0xbe, 0xef]).Offset(0).End()
+        .End();
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory(memoryDescription);
+    const table = new WebAssembly.Table({element: &quot;anyfunc&quot;, initial: 19});
+    const imports = {
+        imp: {
+            memory: memory,
+            table: table,
+        }
+    };
+    assert.throws(() =&gt; new WebAssembly.Instance(module, imports), RangeError, `Element is trying to set an out of bounds table index`);
+    // On Element failure, the Data section shouldn't have executed.
+    const buffer = new Uint8Array(memory.buffer);
+    for (let idx = 0; idx &lt; memSizeInPages * pageSizeInBytes; ++idx) {
+        const value = buffer[idx];
+        assert.eq(value, 0x00);
+    }
+})();
</ins></span></pre></div>
<a id="trunkJSTestswasmjsapitest_Datajs"></a>
<div class="modfile"><h4>Modified: trunk/JSTests/wasm/js-api/test_Data.js (209873 => 209874)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/JSTests/wasm/js-api/test_Data.js        2016-12-15 22:08:26 UTC (rev 209873)
+++ trunk/JSTests/wasm/js-api/test_Data.js        2016-12-15 22:08:38 UTC (rev 209874)
</span><span class="lines">@@ -4,9 +4,18 @@
</span><span class="cx"> const memSizeInPages = 1;
</span><span class="cx"> const pageSizeInBytes = 64 * 1024;
</span><span class="cx"> const memoryDescription = { initial: memSizeInPages, maximum: memSizeInPages };
</span><ins>+const emptyMemory = { initial: 0, maximum: 2 };
</ins><span class="cx"> 
</span><span class="cx"> // FIXME Some corner cases are ill-specified: https://github.com/WebAssembly/design/issues/897
</span><span class="cx"> 
</span><ins>+const assertMemoryAllZero = memory =&gt; {
+    const buffer = new Uint8Array(memory.buffer);
+    for (let idx = 0; idx &lt; buffer.length; ++idx) {
+        const value = buffer[idx];
+        assert.eq(value, 0x00);
+    }
+};
+
</ins><span class="cx"> (function DataSection() {
</span><span class="cx">     const builder = (new Builder())
</span><span class="cx">         .Type().End()
</span><span class="lines">@@ -36,6 +45,40 @@
</span><span class="cx">     }
</span><span class="cx"> })();
</span><span class="cx"> 
</span><ins>+(function DataSectionWithoutMemory() {
+    const builder = (new Builder())
+        .Type().End()
+        .Data()
+          .Segment([0xff]).Offset(0).End()
+        .End();
+    const bin = builder.WebAssembly().get();
+    assert.throws(() =&gt; new WebAssembly.Module(bin), WebAssembly.CompileError, `couldn't parse section Data: Data segments (evaluating 'new WebAssembly.Module(bin)')`);
+})();
+
+(function EmptyDataSectionWithoutMemory() {
+    const builder = (new Builder())
+        .Type().End()
+        .Data()
+          .Segment([]).Offset(0).End()
+        .End();
+    const bin = builder.WebAssembly().get();
+    assert.throws(() =&gt; new WebAssembly.Module(bin), WebAssembly.CompileError, `couldn't parse section Data: Data segments (evaluating 'new WebAssembly.Module(bin)')`);
+})();
+
+(function DataSectionBiggerThanMemory() {
+    const builder = (new Builder())
+        .Type().End()
+        .Import().Memory(&quot;imp&quot;, &quot;memory&quot;, memoryDescription).End()
+        .Data()
+          .Segment(Array(memSizeInPages * pageSizeInBytes + 1).fill(0xff)).Offset(0).End()
+        .End();
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory(memoryDescription);
+    assert.throws(() =&gt; new WebAssembly.Instance(module, { imp: { memory: memory } }), RangeError, `Invalid data segment initialization: segment of 65537 bytes memory of 65536 bytes, at offset 0, segment is too big`);
+    assertMemoryAllZero(memory);
+})();
+
</ins><span class="cx"> (function DataSectionOffTheEnd() {
</span><span class="cx">     const builder = (new Builder())
</span><span class="cx">         .Type().End()
</span><span class="lines">@@ -46,12 +89,8 @@
</span><span class="cx">     const bin = builder.WebAssembly().get();
</span><span class="cx">     const module = new WebAssembly.Module(bin);
</span><span class="cx">     const memory = new WebAssembly.Memory(memoryDescription);
</span><del>-    assert.throws(() =&gt; new WebAssembly.Instance(module, { imp: { memory: memory } }), RangeError, `Data segment initializes memory out of range`);
-    const buffer = new Uint8Array(memory.buffer);
-    for (let idx = 0; idx &lt; memSizeInPages * pageSizeInBytes; ++idx) {
-        const value = buffer[idx];
-        assert.eq(value, 0x00);
-    }
</del><ins>+    assert.throws(() =&gt; new WebAssembly.Instance(module, { imp: { memory: memory } }), RangeError, `Invalid data segment initialization: segment of 1 bytes memory of 65536 bytes, at offset 65536, segment writes outside of memory`);
+    assertMemoryAllZero(memory);
</ins><span class="cx"> })();
</span><span class="cx"> 
</span><span class="cx"> (function DataSectionPartlyOffTheEnd() {
</span><span class="lines">@@ -64,12 +103,8 @@
</span><span class="cx">     const bin = builder.WebAssembly().get();
</span><span class="cx">     const module = new WebAssembly.Module(bin);
</span><span class="cx">     const memory = new WebAssembly.Memory(memoryDescription);
</span><del>-    assert.throws(() =&gt; new WebAssembly.Instance(module, { imp: { memory: memory } }), RangeError, `Data segment initializes memory out of range`);
-    const buffer = new Uint8Array(memory.buffer);
-    for (let idx = 0; idx &lt; memSizeInPages * pageSizeInBytes; ++idx) {
-        const value = buffer[idx];
-        assert.eq(value, 0x00);
-    }
</del><ins>+    assert.throws(() =&gt; new WebAssembly.Instance(module, { imp: { memory: memory } }), RangeError, `Invalid data segment initialization: segment of 2 bytes memory of 65536 bytes, at offset 65535, segment writes outside of memory`);
+    assertMemoryAllZero(memory);
</ins><span class="cx"> })();
</span><span class="cx"> 
</span><span class="cx"> (function DataSectionEmptyOffTheEnd() {
</span><span class="lines">@@ -83,13 +118,23 @@
</span><span class="cx">     const module = new WebAssembly.Module(bin);
</span><span class="cx">     const memory = new WebAssembly.Memory(memoryDescription);
</span><span class="cx">     const instance = new WebAssembly.Instance(module, { imp: { memory: memory } });
</span><del>-    const buffer = new Uint8Array(memory.buffer);
-    for (let idx = 0; idx &lt; memSizeInPages * pageSizeInBytes; ++idx) {
-        const value = buffer[idx];
-        assert.eq(value, 0x00);
-    }
</del><ins>+    assertMemoryAllZero(memory);
</ins><span class="cx"> })();
</span><span class="cx"> 
</span><ins>+(function DataSectionEmptyOffTheEndWithEmptyMemory() {
+    const builder = (new Builder())
+        .Type().End()
+        .Import().Memory(&quot;imp&quot;, &quot;memory&quot;, emptyMemory).End()
+        .Data()
+          .Segment([]).Offset(memSizeInPages * pageSizeInBytes).End()
+        .End();
+    const bin = builder.WebAssembly().get();
+    const module = new WebAssembly.Module(bin);
+    const memory = new WebAssembly.Memory(emptyMemory);
+    const instance = new WebAssembly.Instance(module, { imp: { memory: memory } });
+    assertMemoryAllZero(memory);
+})();
+
</ins><span class="cx"> (function DataSectionSeenByStart() {
</span><span class="cx">     const offset = 1024;
</span><span class="cx">     const builder = (new Builder())
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (209873 => 209874)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-12-15 22:08:26 UTC (rev 209873)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-12-15 22:08:38 UTC (rev 209874)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-12-15  JF Bastien  &lt;jfbastien@apple.com&gt;
+
+        WebAssembly API: improve data section errors, initialize after Element
+        https://bugs.webkit.org/show_bug.cgi?id=165733
+
+        Reviewed by Keith Miller.
+
+        * wasm/WasmModuleParser.cpp:
+        (JSC::Wasm::ModuleParser::parseData): Data section without Memory section or import is a validation error
+        * wasm/js/WebAssemblyModuleRecord.cpp:
+        (JSC::dataSegmentFail):
+        (JSC::WebAssemblyModuleRecord::evaluate): tighten checks (though the spec isn't fully baked), and move after Element initialization
+
</ins><span class="cx"> 2016-12-15  Keith Miller  &lt;keith_miller@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Turn on WebAssembly by default
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmWasmModuleParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp (209873 => 209874)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp        2016-12-15 22:08:26 UTC (rev 209873)
+++ trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp        2016-12-15 22:08:38 UTC (rev 209874)
</span><span class="lines">@@ -724,6 +724,8 @@
</span><span class="cx"> bool ModuleParser::parseData()
</span><span class="cx"> {
</span><span class="cx">     uint32_t segmentCount;
</span><ins>+    if (!m_module-&gt;memory)
+        return false;
</ins><span class="cx">     if (!parseVarUInt32(segmentCount)
</span><span class="cx">         || segmentCount == std::numeric_limits&lt;uint32_t&gt;::max()
</span><span class="cx">         || !m_module-&gt;data.tryReserveCapacity(segmentCount))
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorewasmjsWebAssemblyModuleRecordcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp (209873 => 209874)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp        2016-12-15 22:08:26 UTC (rev 209873)
+++ trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp        2016-12-15 22:08:38 UTC (rev 209874)
</span><span class="lines">@@ -194,28 +194,17 @@
</span><span class="cx">     m_moduleEnvironment.set(vm, this, moduleEnvironment);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template &lt;typename Scope, typename N, typename ...Args&gt;
+NEVER_INLINE static JSValue dataSegmentFail(ExecState* state, Scope&amp; scope, N memorySize, N segmentSize, N offset, Args... args)
+{
+    return throwException(state, scope, createRangeError(state, makeString(ASCIILiteral(&quot;Invalid data segment initialization: segment of &quot;), String::number(segmentSize), ASCIILiteral(&quot; bytes memory of &quot;), String::number(memorySize), ASCIILiteral(&quot; bytes, at offset &quot;), String::number(offset), args...)));
+}
+
</ins><span class="cx"> JSValue WebAssemblyModuleRecord::evaluate(ExecState* state)
</span><span class="cx"> {
</span><span class="cx">     VM&amp; vm = state-&gt;vm();
</span><span class="cx">     auto scope = DECLARE_THROW_SCOPE(vm);
</span><span class="cx"> 
</span><del>-    if (JSWebAssemblyMemory* jsMemory = m_instance-&gt;memory()) {
-        uint8_t* memory = reinterpret_cast&lt;uint8_t*&gt;(jsMemory-&gt;memory()-&gt;memory());
-        auto sizeInBytes = jsMemory-&gt;memory()-&gt;size();
-        if (memory) {
-            const Vector&lt;Wasm::Segment::Ptr&gt;&amp; data = m_instance-&gt;module()-&gt;moduleInformation().data;
-            for (auto&amp; segment : data) {
-                if (segment-&gt;sizeInBytes) {
-                    if (sizeInBytes &lt; segment-&gt;sizeInBytes
-                        || segment-&gt;offset &gt; sizeInBytes
-                        || segment-&gt;offset &gt; sizeInBytes - segment-&gt;sizeInBytes)
-                        return throwException(state, scope, createRangeError(state, ASCIILiteral(&quot;Data segment initializes memory out of range&quot;)));
-                    memcpy(memory + segment-&gt;offset, &amp;segment-&gt;byte(0), segment-&gt;sizeInBytes);
-                }
-            }
-        }
-    }
-
</del><span class="cx">     {
</span><span class="cx">         JSWebAssemblyModule* module = m_instance-&gt;module();
</span><span class="cx">         const Wasm::ModuleInformation&amp; moduleInformation = module-&gt;moduleInformation();
</span><span class="lines">@@ -261,6 +250,26 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    {
+        const Vector&lt;Wasm::Segment::Ptr&gt;&amp; data = m_instance-&gt;module()-&gt;moduleInformation().data;
+        JSWebAssemblyMemory* jsMemory = m_instance-&gt;memory();
+        if (!data.isEmpty()) {
+            RELEASE_ASSERT(jsMemory); // It is a validation error for a Data section to exist without a Memory section or import.
+            uint8_t* memory = reinterpret_cast&lt;uint8_t*&gt;(jsMemory-&gt;memory()-&gt;memory());
+            RELEASE_ASSERT(memory);
+            auto sizeInBytes = jsMemory-&gt;memory()-&gt;size();
+            for (auto&amp; segment : data) {
+                if (segment-&gt;sizeInBytes) {
+                    if (UNLIKELY(sizeInBytes &lt; segment-&gt;sizeInBytes))
+                        return dataSegmentFail(state, scope, sizeInBytes, segment-&gt;sizeInBytes, segment-&gt;offset, ASCIILiteral(&quot;, segment is too big&quot;));
+                    if (UNLIKELY(segment-&gt;offset &gt; sizeInBytes - segment-&gt;sizeInBytes))
+                        return dataSegmentFail(state, scope, sizeInBytes, segment-&gt;sizeInBytes, segment-&gt;offset, ASCIILiteral(&quot;, segment writes outside of memory&quot;));
+                    memcpy(memory + segment-&gt;offset, &amp;segment-&gt;byte(0), segment-&gt;sizeInBytes);
+                }
+            }
+        }
+    }
+
</ins><span class="cx">     if (WebAssemblyFunction* startFunction = m_startFunction.get()) {
</span><span class="cx">         ProtoCallFrame protoCallFrame;
</span><span class="cx">         protoCallFrame.init(nullptr, startFunction, JSValue(), 1, nullptr);
</span><span class="lines">@@ -267,6 +276,7 @@
</span><span class="cx">         startFunction-&gt;call(vm, &amp;protoCallFrame);
</span><span class="cx">         RETURN_IF_EXCEPTION(scope, { });
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     return jsUndefined();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>