From f8f7dd3296dc82905e2f8dbefabd5d48d5b63123 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 20 Feb 2026 16:02:10 +0100 Subject: [PATCH] Update raygui.h --- src/raygui.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/raygui.h b/src/raygui.h index 67c16be..4b31869 100644 --- a/src/raygui.h +++ b/src/raygui.h @@ -5124,19 +5124,18 @@ static const char **GetTextLines(const char *text, int *count) #define RAYGUI_MAX_TEXT_LINES 128 static const char *lines[RAYGUI_MAX_TEXT_LINES] = { 0 }; - for (int i = 0; i < RAYGUI_MAX_TEXT_LINES; i++) lines[i] = NULL; // Init NULL pointers to substrings + for (int i = 0; i < RAYGUI_MAX_TEXT_LINES; i++) lines[i] = NULL; // Init NULL pointers to substrings int textLength = (int)strlen(text); lines[0] = text; *count = 1; - for (int i = 0, k = 0; (i < textLength) && (*count < RAYGUI_MAX_TEXT_LINES); i++) + for (int i = 0; (i < textLength) && (*count < RAYGUI_MAX_TEXT_LINES); i++) { - if (text[i] == '\n') + if ((text[i] == '\n') && ((i + 1) < textLength)) { - k++; - lines[k] = &text[i + 1]; // WARNING: next value is valid? + lines[*count] = &text[i + 1]; *count += 1; } }