Skip to content

Commit 987e7fd

Browse files
authored
Fix bug in Clay_SetPointerState that causes null pointer deref (#33)
1 parent 948b7ce commit 987e7fd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clay.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3091,8 +3091,9 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
30913091
Clay__treeNodeVisited.internalArray[dfsBuffer.length - 1] = true;
30923092
Clay_LayoutElement *currentElement = Clay_LayoutElementArray_Get(&Clay__layoutElements, Clay__int32_tArray_Get(&dfsBuffer, (int)dfsBuffer.length - 1));
30933093
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
3094-
if ((mapItem && Clay__PointIsInsideRect(position, mapItem->boundingBox)) || (!mapItem && Clay__PointIsInsideRect(position, CLAY__INIT(Clay_BoundingBox) {0,0, currentElement->dimensions.width, currentElement->dimensions.height}))) {
3094+
if (mapItem && Clay__PointIsInsideRect(position, mapItem->boundingBox)) {
30953095
Clay__ElementIdArray_Add(&Clay__pointerOverIds, mapItem->elementId);
3096+
30963097
if (currentElement->elementType == CLAY__LAYOUT_ELEMENT_TYPE_TEXT) {
30973098
dfsBuffer.length--;
30983099
continue;
@@ -3343,4 +3344,4 @@ freely, subject to the following restrictions:
33433344
33443345
3. This notice may not be removed or altered from any source
33453346
distribution.
3346-
*/
3347+
*/

0 commit comments

Comments
 (0)