From 8d3cadc52ea51cff93211e138c57384415abc9a8 Mon Sep 17 00:00:00 2001 From: Shivam7-1 <55046031+Shivam7-1@users.noreply.github.com> Date: Sat, 21 Dec 2024 17:04:07 +0530 Subject: [PATCH 1/2] initial fuzzing support --- fuzz/fuzzing_target.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 fuzz/fuzzing_target.cc diff --git a/fuzz/fuzzing_target.cc b/fuzz/fuzzing_target.cc new file mode 100644 index 0000000..cabf463 --- /dev/null +++ b/fuzz/fuzzing_target.cc @@ -0,0 +1,24 @@ +#include "clay.h" +#include +#include + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + if (size < sizeof(Clay_String)) return 0; + + Clay_String testString = { .length = size, .chars = (const char *)data }; + + Clay_Dimensions dimensions = MeasureText(&testString, NULL); + + // Call other critical functions + Clay_Arena arena = Clay_CreateArenaWithCapacityAndMemory(1024, (void*)data); + Clay_Initialize(arena, (Clay_Dimensions){1024, 768}); + Clay_SetPointerState((Clay_Vector2){0, 0}, false); + Clay_BeginLayout(); + Clay_EndLayout(); + + // Handle pointer state changes + Clay_SetPointerState((Clay_Vector2){1, 1}, true); + Clay_SetPointerState((Clay_Vector2){2, 2}, false); + + return 0; +} From 63a74a92a80cafbab9dfa71d73cc1b04c1dea553 Mon Sep 17 00:00:00 2001 From: Shivam7-1 <55046031+Shivam7-1@users.noreply.github.com> Date: Sun, 22 Dec 2024 21:10:58 +0530 Subject: [PATCH 2/2] Rename fuzzing_target.cc to fuzzing_target.c --- fuzz/{fuzzing_target.cc => fuzzing_target.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename fuzz/{fuzzing_target.cc => fuzzing_target.c} (100%) diff --git a/fuzz/fuzzing_target.cc b/fuzz/fuzzing_target.c similarity index 100% rename from fuzz/fuzzing_target.cc rename to fuzz/fuzzing_target.c