From ff7917798c927d6a6f323d717b9a2c73f3a3bdbe Mon Sep 17 00:00:00 2001 From: Nic Barker Date: Mon, 23 Jun 2025 10:10:02 +1000 Subject: [PATCH] [Core] Avoid calling measure text function with length zero --- clay.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clay.h b/clay.h index 5dd2bc6..0d5b69f 100644 --- a/clay.h +++ b/clay.h @@ -1643,7 +1643,10 @@ Clay__MeasureTextCacheItem *Clay__MeasureTextCached(Clay_String *text, Clay_Text char current = text->chars[end]; if (current == ' ' || current == '\n') { int32_t length = end - start; - Clay_Dimensions dimensions = Clay__MeasureText(CLAY__INIT(Clay_StringSlice) { .length = length, .chars = &text->chars[start], .baseChars = text->chars }, config, context->measureTextUserData); + Clay_Dimensions dimensions = {}; + if (length > 0) { + dimensions = Clay__MeasureText(CLAY__INIT(Clay_StringSlice) {.length = length, .chars = &text->chars[start], .baseChars = text->chars}, config, context->measureTextUserData); + } measured->minWidth = CLAY__MAX(dimensions.width, measured->minWidth); measuredHeight = CLAY__MAX(measuredHeight, dimensions.height); if (current == ' ') {