[lib/Fuzzer] fix build with assertions

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238235 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Kostya Serebryany 2015-05-26 19:29:33 +00:00
parent 890a876e0e
commit f580f3683c
2 changed files with 4 additions and 3 deletions

View File

@ -19,6 +19,7 @@ namespace fuzzer {
size_t CrossOver(const uint8_t *Data1, size_t Size1,
const uint8_t *Data2, size_t Size2,
uint8_t *Out, size_t MaxOutSize) {
assert(Size1 || Size2);
MaxOutSize = rand() % MaxOutSize + 1;
size_t OutPos = 0;
size_t Pos1 = 0;

View File

@ -287,7 +287,7 @@ void Fuzzer::MutateAndTestOne(Unit *U) {
size_t Size = U->size();
U->resize(Options.MaxLen);
size_t NewSize = USF.Mutate(U->data(), Size, U->size());
assert(NewSize > 0 && NewSize <= Options.MaxLen);
assert(NewSize > 0 && NewSize <= (size_t)Options.MaxLen);
U->resize(NewSize);
RunOneAndUpdateCorpus(*U);
size_t NumTraceBasedMutations = StopTraceRecording();
@ -309,13 +309,13 @@ void Fuzzer::Loop(size_t NumIterations) {
CurrentUnit = Corpus[J1];
MutateAndTestOne(&CurrentUnit);
// Now, cross with others.
if (Options.DoCrossOver) {
if (Options.DoCrossOver && !Corpus[J1].empty()) {
for (size_t J2 = 0; J2 < Corpus.size(); J2++) {
CurrentUnit.resize(Options.MaxLen);
size_t NewSize = USF.CrossOver(
Corpus[J1].data(), Corpus[J1].size(), Corpus[J2].data(),
Corpus[J2].size(), CurrentUnit.data(), CurrentUnit.size());
assert(NewSize > 0 && NewSize <= Options.MaxLen);
assert(NewSize > 0 && NewSize <= (size_t)Options.MaxLen);
CurrentUnit.resize(NewSize);
MutateAndTestOne(&CurrentUnit);
}