summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2021-12-28 17:03:40 -0800
committerGitHub <noreply@github.com>2021-12-28 17:03:40 -0800
commit3352e23d5aea9c8fc24147ae6210c7fcee2db0fc (patch)
treee4a198be5f2beecdac7b0ef70ba3dd5bf2364aeb
parentdb23896425e78fbccff5ac3e4ec1799097cf3cac (diff)
downloadbinaryen-3352e23d5aea9c8fc24147ae6210c7fcee2db0fc.tar.gz
binaryen-3352e23d5aea9c8fc24147ae6210c7fcee2db0fc.tar.bz2
binaryen-3352e23d5aea9c8fc24147ae6210c7fcee2db0fc.zip
[Fuzzer] Allow empty data in --translate-to-fuzz (#4406)
When a parameter and a member variable have the same name within a constructor, to access (and change) the member variable, we need to either use `this->` or change the name of the parameter. The current code ended up changing the parameter and didn't affect the status of the member variable, which remained empty.
-rw-r--r--src/tools/fuzzing/random.cpp4
-rw-r--r--test/unit/test_fuzz_empty_data.py14
2 files changed, 16 insertions, 2 deletions
diff --git a/src/tools/fuzzing/random.cpp b/src/tools/fuzzing/random.cpp
index 3d8297c15..8beda478b 100644
--- a/src/tools/fuzzing/random.cpp
+++ b/src/tools/fuzzing/random.cpp
@@ -20,8 +20,8 @@
namespace wasm {
-Random::Random(std::vector<char>&& bytes, FeatureSet features)
- : bytes(std::move(bytes)), features(features) {
+Random::Random(std::vector<char>&& bytes_, FeatureSet features)
+ : bytes(std::move(bytes_)), features(features) {
// Ensure there is *some* input to be read.
if (bytes.empty()) {
bytes.push_back(0);
diff --git a/test/unit/test_fuzz_empty_data.py b/test/unit/test_fuzz_empty_data.py
new file mode 100644
index 000000000..3206fcead
--- /dev/null
+++ b/test/unit/test_fuzz_empty_data.py
@@ -0,0 +1,14 @@
+import os
+import tempfile
+from scripts.test import shared
+from . import utils
+
+
+class EmptyDataFuzzTest(utils.BinaryenTestCase):
+ def test_empty_data(self):
+ try:
+ temp = tempfile.NamedTemporaryFile(delete=False).name
+ shared.run_process(shared.WASM_OPT + ['-ttf', temp],
+ capture_output=True)
+ finally:
+ os.unlink(temp)