RyanLamansky / dotnet-webassembly

Create, read, modify, write and execute WebAssembly (WASM) files from .NET-based applications.
Apache License 2.0
792 stars 74 forks source link

Fix for "WebAssemblyValueType 7 not recognized" (#35) #36

Closed munik closed 3 years ago

munik commented 3 years ago

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.

@RyanLamansky I wasn't sure where to put the test. CompilerTests.cs seemed like the right place, but after reading through it, nothing else tested Compile.FromBinary -- please let me know if there's a better place to put this or if I should create a new file.

RyanLamansky commented 3 years ago

Thank you!