Skip to content

Commit

Permalink
Simplify string resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybuka committed Nov 6, 2020
1 parent 5130879 commit e5869dd
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/libfuzzer/libfuzzer_mutator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,8 @@ std::string Mutator::MutateString(const std::string& value,
// any 8 bit types.
if (!std::uniform_int_distribution<uint16_t>(0, 20)(*random())) return {};
std::string result = value;
std::string::size_type new_size = 0;
if (size_increase_hint >= 0 || static_cast<std::string::size_type>(
-size_increase_hint) <= value.size()) {
new_size = value.size() + size_increase_hint;
}
result.resize(new_size);
if (result.empty()) result.push_back(0);
int new_size = value.size() + size_increase_hint;
result.resize(std::max(1, new_size));
result.resize(LLVMFuzzerMutate(reinterpret_cast<uint8_t*>(&result[0]),
value.size(), result.size()));
return result;
Expand Down

0 comments on commit e5869dd

Please sign in to comment.