Skip to content

Commit fa77183

Browse files
author
MarcoFalke
committed
fuzz: Avoid OOM in system fuzz target
1 parent d67330d commit fa77183

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/test/fuzz/fuzz.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#include <functional>
1212
#include <string_view>
1313

14+
#define LIMITED_WHILE(condition, limit) \
15+
for (unsigned _count{limit}; (condition) && _count; --_count)
16+
1417
using FuzzBufferType = Span<const uint8_t>;
1518

1619
using TypeTestOneInput = std::function<void(FuzzBufferType)>;

src/test/fuzz/system.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ FUZZ_TARGET(system)
3131
SetupHelpOptions(args_manager);
3232
}
3333

34-
while (fuzzed_data_provider.ConsumeBool()) {
34+
LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 3000)
35+
{
3536
CallOneOf(
3637
fuzzed_data_provider,
3738
[&] {

0 commit comments

Comments
 (0)