From c4e1e907bdc9c8879aaed8bd8bb1cd91ee97b30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20Sme=CC=8Cly=CC=81?= Date: Wed, 2 Oct 2024 02:49:02 +0200 Subject: [PATCH] Fix crash when mapItem is null --- clay.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clay.h b/clay.h index 2bb857d..21c1f72 100644 --- a/clay.h +++ b/clay.h @@ -3092,7 +3092,10 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) { Clay_LayoutElement *currentElement = Clay_LayoutElementArray_Get(&Clay__layoutElements, Clay__int32_tArray_Get(&dfsBuffer, (int)dfsBuffer.length - 1)); Clay_LayoutElementHashMapItem *mapItem = Clay__GetHashMapItem(currentElement->id); // TODO I wish there was a way around this, maybe the fact that it's essentially a binary tree limits the cost, have to measure if ((mapItem && Clay__PointIsInsideRect(position, mapItem->boundingBox)) || (!mapItem && Clay__PointIsInsideRect(position, CLAY__INIT(Clay_BoundingBox) {0,0, currentElement->dimensions.width, currentElement->dimensions.height}))) { - Clay__ElementIdArray_Add(&Clay__pointerOverIds, mapItem->elementId); + if (mapItem) { + Clay__ElementIdArray_Add(&Clay__pointerOverIds, mapItem->elementId); + } + if (currentElement->elementType == CLAY__LAYOUT_ELEMENT_TYPE_TEXT) { dfsBuffer.length--; continue; @@ -3343,4 +3346,4 @@ freely, subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. -*/ \ No newline at end of file +*/