From bf5eecc71f63d1bca76fdb377a1d231066f9258d Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Wed, 15 May 2024 07:16:45 -0700 Subject: [PATCH] [parser] Don't crash for files that don't end in newlines (#3981) The parser assumes all lines end in newlines, but sometimes this isn't true. Check for a null terminator along with '\n' when stripping leading spaces. --- parser/raylib_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser/raylib_parser.c b/parser/raylib_parser.c index ec1d490e..3e36f41f 100644 --- a/parser/raylib_parser.c +++ b/parser/raylib_parser.c @@ -1243,7 +1243,7 @@ static char **GetTextLines(const char *buffer, int length, int *linesCount) while ((bufferPtr[index] == ' ') || (bufferPtr[index] == '\t')) index++; int j = 0; - while (bufferPtr[index + j] != '\n') + while (bufferPtr[index + j] != '\n' && bufferPtr[index + j] != '\0') { lines[i][j] = bufferPtr[index + j]; j++;