Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Fix null pointer deref in Clay_SetPointerState #33

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions clay.h
Original file line number Diff line number Diff line change
Expand Up @@ -3091,8 +3091,9 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
Clay__treeNodeVisited.internalArray[dfsBuffer.length - 1] = true;
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}))) {
if (mapItem && Clay__PointIsInsideRect(position, mapItem->boundingBox)) {
Clay__ElementIdArray_Add(&Clay__pointerOverIds, mapItem->elementId);

if (currentElement->elementType == CLAY__LAYOUT_ELEMENT_TYPE_TEXT) {
dfsBuffer.length--;
continue;
Expand Down Expand Up @@ -3343,4 +3344,4 @@ freely, subject to the following restrictions:

3. This notice may not be removed or altered from any source
distribution.
*/
*/