[libFuzzer] Pass the current size to Mutate in MinimizeCrashLoop (#223470) Fixes #149942. MinimizeCrashLoop passed U.size() to every MD.Mutate call in the mutate_depth loop, so following mutations operated on a stale size. Track the size across mutations, like MutateAndTestOne already does. GitOrigin-RevId: c7d4921b39bf5710968872213935198efbb310fd
diff --git a/FuzzerLoop.cpp b/FuzzerLoop.cpp index 39ccf50..5511dfa 100644 --- a/FuzzerLoop.cpp +++ b/FuzzerLoop.cpp
@@ -921,14 +921,16 @@ return; while (!TimedOut() && TotalNumberOfRuns < Options.MaxNumberOfRuns) { MD.StartMutationSequence(); - memcpy(CurrentUnitData, U.data(), U.size()); + size_t Size = U.size(); + memcpy(CurrentUnitData, U.data(), Size); for (int i = 0; i < Options.MutateDepth; i++) { - size_t NewSize = MD.Mutate(CurrentUnitData, U.size(), MaxMutationLen); + size_t NewSize = MD.Mutate(CurrentUnitData, Size, MaxMutationLen); assert(NewSize > 0 && NewSize <= MaxMutationLen); ExecuteCallback(CurrentUnitData, NewSize); PrintPulseAndReportSlowInput(CurrentUnitData, NewSize); TryDetectingAMemoryLeak(CurrentUnitData, NewSize, /*DuringInitialCorpusExecution*/ false); + Size = NewSize; } } }