Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions fuzz/fuzz_eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,20 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
return 0;

JSRuntime *rt = JS_NewRuntime();
if (!rt)
return 0;

// Set resource limits immediately after runtime creation to prevent resource exhaustion
JS_SetMemoryLimit(rt, 0x4000000); // 64 MB memory limit
JS_SetMaxStackSize(rt, 0x10000); // 64 KB stack limit
JS_SetGCThreshold(rt, 0x400000); // 4 MB GC threshold

JSContext *ctx = JS_NewContext(rt);
if (!ctx) {
JS_FreeRuntime(rt);
return 0;
}

test_one_input_init(rt, ctx);

uint8_t *null_terminated_data = malloc(size + 1);
Expand Down