Skip to content

Commit 3352e23

Browse files
authored
[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.
1 parent db23896 commit 3352e23

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/tools/fuzzing/random.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
namespace wasm {
2222

23-
Random::Random(std::vector<char>&& bytes, FeatureSet features)
24-
: bytes(std::move(bytes)), features(features) {
23+
Random::Random(std::vector<char>&& bytes_, FeatureSet features)
24+
: bytes(std::move(bytes_)), features(features) {
2525
// Ensure there is *some* input to be read.
2626
if (bytes.empty()) {
2727
bytes.push_back(0);

test/unit/test_fuzz_empty_data.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import os
2+
import tempfile
3+
from scripts.test import shared
4+
from . import utils
5+
6+
7+
class EmptyDataFuzzTest(utils.BinaryenTestCase):
8+
def test_empty_data(self):
9+
try:
10+
temp = tempfile.NamedTemporaryFile(delete=False).name
11+
shared.run_process(shared.WASM_OPT + ['-ttf', temp],
12+
capture_output=True)
13+
finally:
14+
os.unlink(temp)

0 commit comments

Comments
 (0)