diff options
author | Thomas Lively <tlively@google.com> | 2023-04-05 06:10:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-05 08:10:23 -0500 |
commit | 9ee557aa7fbb494b222c4692cbef1c2be983e532 (patch) | |
tree | 45af4d3506ca6f259914e5a23d88f19bebbf62c6 /src | |
parent | d7c24bc6796616b821b6b0dfcd649dbf1c821cb3 (diff) | |
download | binaryen-9ee557aa7fbb494b222c4692cbef1c2be983e532.tar.gz binaryen-9ee557aa7fbb494b222c4692cbef1c2be983e532.tar.bz2 binaryen-9ee557aa7fbb494b222c4692cbef1c2be983e532.zip |
Fix a crash in MemoryPacking due to an unreachable pointer (#5623)
Previously, the pointer type for newly emitted instructions was determined by
the type of the destination pointer on a memory.init instruction, but that did
not take into account that the destination pointer may be unreachable. Properly
look up the pointer type on the memory instead to fix the problem.
Fixes #5620.
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/MemoryPacking.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/passes/MemoryPacking.cpp b/src/passes/MemoryPacking.cpp index 608bc1af2..5178db3ac 100644 --- a/src/passes/MemoryPacking.cpp +++ b/src/passes/MemoryPacking.cpp @@ -701,7 +701,7 @@ void MemoryPacking::createReplacements(Module* module, // Calculate dest, either as a const or as an addition to the dest local Expression* dest; - Type ptrType = init->dest->type; + Type ptrType = module->getMemory(init->memory)->indexType; if (auto* c = init->dest->dynCast<Const>()) { dest = builder.makeConstPtr(c->value.getInteger() + bytesWritten, ptrType); |