Skip to content

Commit

Permalink
Fix for "WebAssemblyValueType 7 not recognized" (#35)
Browse files Browse the repository at this point in the history
When compiling a WASM binary, when there were N global imports in the
import section as well as M global variables in the global section, in
some (perhaps not all) circumstances, the compiler would try to read N+M
entries from the global section rather than just M.

In the reported issue, this resulted in an attempt to interpret the
adjacent bytes as the content type of the next global variable, which was
not a valid WebAssemblyValueType.
  • Loading branch information
Matthew Rodatus committed May 22, 2021
1 parent 67a4830 commit 2ea4961
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion WebAssembly/Runtime/Compile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ void CreateMemoryField()

var emptySignature = Signature.Empty;

for (var i = 0; i < globals.Length; i++)
for (var i = 0; i < count; i++)
{
var contentType = (WebAssemblyValueType)reader.ReadVarInt7();
var isMutable = reader.ReadVarUInt1() == 1;
Expand Down

0 comments on commit 2ea4961

Please sign in to comment.