mirror of
https://github.com/nicbarker/clay.git
synced 2025-05-15 14:58:03 +00:00
Compare commits
5 Commits
dc2229acb9
...
a08a91c985
Author | SHA1 | Date | |
---|---|---|---|
|
a08a91c985 | ||
|
766325c395 | ||
|
5afdf3f8c9 | ||
|
63a74a92a8 | ||
|
8d3cadc52e |
4
clay.h
4
clay.h
@ -1443,7 +1443,7 @@ Clay__MeasureTextCacheItem *Clay__MeasureTextCached(Clay_String *text, Clay_Text
|
|||||||
measured = Clay__MeasureTextCacheItemArray_Get(&context->measureTextHashMapInternal, newItemIndex);
|
measured = Clay__MeasureTextCacheItemArray_Get(&context->measureTextHashMapInternal, newItemIndex);
|
||||||
} else {
|
} else {
|
||||||
if (context->measureTextHashMapInternal.length == context->measureTextHashMapInternal.capacity - 1) {
|
if (context->measureTextHashMapInternal.length == context->measureTextHashMapInternal.capacity - 1) {
|
||||||
if (context->booleanWarnings.maxTextMeasureCacheExceeded) {
|
if (!context->booleanWarnings.maxTextMeasureCacheExceeded) {
|
||||||
context->errorHandler.errorHandlerFunction(CLAY__INIT(Clay_ErrorData) {
|
context->errorHandler.errorHandlerFunction(CLAY__INIT(Clay_ErrorData) {
|
||||||
.errorType = CLAY_ERROR_TYPE_ELEMENTS_CAPACITY_EXCEEDED,
|
.errorType = CLAY_ERROR_TYPE_ELEMENTS_CAPACITY_EXCEEDED,
|
||||||
.errorText = CLAY_STRING("Clay ran out of capacity while attempting to measure text elements. Try using Clay_SetMaxElementCount() with a higher value."),
|
.errorText = CLAY_STRING("Clay ran out of capacity while attempting to measure text elements. Try using Clay_SetMaxElementCount() with a higher value."),
|
||||||
@ -3589,7 +3589,7 @@ uint32_t Clay_MinMemorySize(void) {
|
|||||||
Clay_Context* currentContext = Clay_GetCurrentContext();
|
Clay_Context* currentContext = Clay_GetCurrentContext();
|
||||||
if (currentContext) {
|
if (currentContext) {
|
||||||
fakeContext.maxElementCount = currentContext->maxElementCount;
|
fakeContext.maxElementCount = currentContext->maxElementCount;
|
||||||
fakeContext.maxMeasureTextCacheWordCount = currentContext->maxElementCount;
|
fakeContext.maxMeasureTextCacheWordCount = currentContext->maxMeasureTextCacheWordCount;
|
||||||
}
|
}
|
||||||
// Reserve space in the arena for the context, important for calculating min memory size correctly
|
// Reserve space in the arena for the context, important for calculating min memory size correctly
|
||||||
Clay__Context_Allocate_Arena(&fakeContext.internalArena);
|
Clay__Context_Allocate_Arena(&fakeContext.internalArena);
|
||||||
|
24
fuzz/fuzzing_target.c
Normal file
24
fuzz/fuzzing_target.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include "clay.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user