diff options
author | Alon Zakai <azakai@google.com> | 2024-05-23 16:06:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-23 16:06:19 -0700 |
commit | 9b61eb3ab9c9f7d87140acf8a0c43c5b965773dc (patch) | |
tree | 32644530f45fedfff39676c5b8e04203f47a7c17 /src/tools/fuzzing/fuzzing.cpp | |
parent | 06cbe01f2774955ed3f23994b3ea1db58e43a4d8 (diff) | |
download | binaryen-9b61eb3ab9c9f7d87140acf8a0c43c5b965773dc.tar.gz binaryen-9b61eb3ab9c9f7d87140acf8a0c43c5b965773dc.tar.bz2 binaryen-9b61eb3ab9c9f7d87140acf8a0c43c5b965773dc.zip |
Fix fuzzer generation of a DataSegment + add validation that would have caught it (#6626)
The DataSegment was manually added to .dataSegments, but we need to add it
using addDataSegment so the maps are updated and getDataSegment(name)
works.
Also add validation that would have caught this earlier: check that each item in
the item lists can be fetched by name.
Diffstat (limited to 'src/tools/fuzzing/fuzzing.cpp')
-rw-r--r-- | src/tools/fuzzing/fuzzing.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/tools/fuzzing/fuzzing.cpp b/src/tools/fuzzing/fuzzing.cpp index f4f059deb..57c7ec6b0 100644 --- a/src/tools/fuzzing/fuzzing.cpp +++ b/src/tools/fuzzing/fuzzing.cpp @@ -224,13 +224,14 @@ void TranslateToFuzzReader::setupMemory() { auto segment = builder.makeDataSegment(); segment->memory = memory->name; segment->offset = builder.makeConst(int32_t(0)); - segment->setName(Name::fromInt(0), false); - wasm.dataSegments.push_back(std::move(segment)); + segment->setName(Names::getValidDataSegmentName(wasm, Name::fromInt(0)), + false); auto num = upTo(USABLE_MEMORY * 2); for (size_t i = 0; i < num; i++) { auto value = upTo(512); - wasm.dataSegments[0]->data.push_back(value >= 256 ? 0 : (value & 0xff)); + segment->data.push_back(value >= 256 ? 0 : (value & 0xff)); } + wasm.addDataSegment(std::move(segment)); } } |