<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Parse the entire WebAssembly modules"
href="https://bugs.webkit.org/show_bug.cgi?id=147393#c13">Comment # 13</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Parse the entire WebAssembly modules"
href="https://bugs.webkit.org/show_bug.cgi?id=147393">bug 147393</a>
from <span class="vcard"><a class="email" href="mailto:sukolsak@gmail.com" title="Sukolsak Sakshuwong <sukolsak@gmail.com>"> <span class="fn">Sukolsak Sakshuwong</span></a>
</span></b>
<pre>Thanks.
(In reply to <a href="show_bug.cgi?id=147393#c10">comment #10</a>)
<span class="quote">> 1. Use a do-while loop because it is more succinct and easier to read.</span >
Done.
<span class="quote">> 2. Use a uint64_t local value instead of storing into the result directly.
> Using the local allows the compiler to put it in a register, and register
> operations are cheap. We only incur the memory write to result at the end.</span >
Used a local value.
<span class="quote">> 3. When the computation is done,
> (1) break out of the loop,
> (2) validate that the computed value is within size of a uint32, and
> (3) copy the local value into the result.
>
> 4. The loop can loop while (value < numeric_limits<uint32_t>::max()). This
> ensures that we don't overflow our uint64_t local value and that the
> validation check in 3.2 will work as expected.</span >
As discussed on IRC, checking that (value < numeric_limits<uint32_t>::max()) is not enough, because the bytes could be 0x80 0x80 0x80 0x80 0x80 ... . Checking that the number of bytes doesn't exceed 5 and that the fifth byte is <= 0b00001111 should prevent that and also eliminate the need for uint64_t.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>