mirror of
https://github.com/nicbarker/clay.git
synced 2025-09-18 04:26:18 +00:00
[Core] Fix an out of bounds access for single newline characters
This commit is contained in:
parent
b25a31c1a1
commit
6b03a215b7
2
clay.h
2
clay.h
|
@ -2512,7 +2512,7 @@ void Clay__CalculateFinalLayout(void) {
|
||||||
// measuredWord->length == 0 means a newline character
|
// measuredWord->length == 0 means a newline character
|
||||||
else if (measuredWord->length == 0 || lineWidth + measuredWord->width > containerElement->dimensions.width) {
|
else if (measuredWord->length == 0 || lineWidth + measuredWord->width > containerElement->dimensions.width) {
|
||||||
// Wrapped text lines list has overflowed, just render out the line
|
// Wrapped text lines list has overflowed, just render out the line
|
||||||
bool finalCharIsSpace = textElementData->text.chars[lineStartOffset + lineLengthChars - 1] == ' ';
|
bool finalCharIsSpace = textElementData->text.chars[CLAY__MAX(lineStartOffset + lineLengthChars - 1, 0)] == ' ';
|
||||||
Clay__WrappedTextLineArray_Add(&context->wrappedTextLines, CLAY__INIT(Clay__WrappedTextLine) { { lineWidth + (finalCharIsSpace ? -spaceWidth : 0), lineHeight }, { .length = lineLengthChars + (finalCharIsSpace ? -1 : 0), .chars = &textElementData->text.chars[lineStartOffset] } });
|
Clay__WrappedTextLineArray_Add(&context->wrappedTextLines, CLAY__INIT(Clay__WrappedTextLine) { { lineWidth + (finalCharIsSpace ? -spaceWidth : 0), lineHeight }, { .length = lineLengthChars + (finalCharIsSpace ? -1 : 0), .chars = &textElementData->text.chars[lineStartOffset] } });
|
||||||
textElementData->wrappedLines.length++;
|
textElementData->wrappedLines.length++;
|
||||||
if (lineLengthChars == 0 || measuredWord->length == 0) {
|
if (lineLengthChars == 0 || measuredWord->length == 0) {
|
||||||
|
|
Loading…
Reference in a new issue