diff options
author | Alon Zakai <azakai@google.com> | 2024-06-17 15:21:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-17 15:21:05 -0700 |
commit | b377b6f175cf5904d8e65eb8f2184c7379f97297 (patch) | |
tree | 3cbcee20b4d712389485536b0ca38dbe60358f70 /test/lit/binary/data-names.test.wasm | |
parent | 1dd05202ced86548361d5efc439ad106007f8bb8 (diff) | |
download | binaryen-b377b6f175cf5904d8e65eb8f2184c7379f97297.tar.gz binaryen-b377b6f175cf5904d8e65eb8f2184c7379f97297.tar.bz2 binaryen-b377b6f175cf5904d8e65eb8f2184c7379f97297.zip |
Fix DataSegment name handling (#6673)
The code used i instead of index, as in this pseudocode:
for i in range(num_names):
index = readU32LEB() # index of the data segment to name
name = readName() # name to give that segment
data[i] = name # XXX 'i' should be 'index'
That (funnily enough) happened to always work before since we write names in
order. That is, normally given segments A,B,C we'd write then in the names section
as A,B,C. Then the reader, which had the bug, would always have i and index
identical in value anyhow. But if a wasm producer used different indexes, a
problem could happen.
To test this, add a binary file that has a reversed name section.
Fixes #6672
Diffstat (limited to 'test/lit/binary/data-names.test.wasm')
-rw-r--r-- | test/lit/binary/data-names.test.wasm | bin | 0 -> 119 bytes |
1 files changed, 0 insertions, 0 deletions
diff --git a/test/lit/binary/data-names.test.wasm b/test/lit/binary/data-names.test.wasm Binary files differnew file mode 100644 index 000000000..7384aea50 --- /dev/null +++ b/test/lit/binary/data-names.test.wasm |