Compare commits

...

3 Commits

Author SHA1 Message Date
Jackson Novak
203035cc17
Merge fa0e566438 into 06167b4f4b 2025-04-12 23:18:30 +02:00
Nic Barker
06167b4f4b [Core] Fix a potential null pointer deref in scroll GetScrollContainerData
Some checks failed
CMake on multiple platforms / build (Release, cl, cl, windows-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, clang, clang++, ubuntu-latest) (push) Has been cancelled
CMake on multiple platforms / build (Release, gcc, g++, ubuntu-latest) (push) Has been cancelled
2025-04-12 11:27:10 +12:00
Oglo12
fa0e566438 [README] Fix Clay_String definition in README.md file.
Added `.isStaticallyAllocated` as a field,
and changed `int length` to `int32_t length` to
reflect the actual code.
2025-04-08 15:56:42 -05:00
2 changed files with 15 additions and 3 deletions

View File

@ -1787,7 +1787,8 @@ Note: when using the debug tools, their internal colors are represented as 0-255
```C
typedef struct {
int length;
bool isStaticallyAllocated;
int32_t length;
const char *chars;
} Clay_String;
```
@ -1796,7 +1797,14 @@ typedef struct {
**Fields**
**`.length`** - `int`
**`.isStaticallyAllocated`** - `bool`
Whether or not the string is statically allocated, or in other words, whether
or not it lives for the entire lifetime of the program.
---
**`.length`** - `int32_t`
The number of characters in the string, _not including an optional null terminator._

6
clay.h
View File

@ -4118,11 +4118,15 @@ Clay_ScrollContainerData Clay_GetScrollContainerData(Clay_ElementId id) {
for (int32_t i = 0; i < context->scrollContainerDatas.length; ++i) {
Clay__ScrollContainerDataInternal *scrollContainerData = Clay__ScrollContainerDataInternalArray_Get(&context->scrollContainerDatas, i);
if (scrollContainerData->elementId == id.id) {
Clay_ScrollElementConfig *scrollElementConfig = Clay__FindElementConfigWithType(scrollContainerData->layoutElement, CLAY__ELEMENT_CONFIG_TYPE_SCROLL).scrollElementConfig;
if (!scrollElementConfig) { // This can happen on the first frame before a scroll container is declared
return CLAY__INIT(Clay_ScrollContainerData) CLAY__DEFAULT_STRUCT;
}
return CLAY__INIT(Clay_ScrollContainerData) {
.scrollPosition = &scrollContainerData->scrollPosition,
.scrollContainerDimensions = { scrollContainerData->boundingBox.width, scrollContainerData->boundingBox.height },
.contentDimensions = scrollContainerData->contentSize,
.config = *Clay__FindElementConfigWithType(scrollContainerData->layoutElement, CLAY__ELEMENT_CONFIG_TYPE_SCROLL).scrollElementConfig,
.config = *scrollElementConfig,
.found = true
};
}