From 05f04e47a5c31f76bfbedcaac1e116684d13f98f Mon Sep 17 00:00:00 2001 From: Peter0x44 Date: Tue, 14 May 2024 23:12:45 +0100 Subject: [PATCH] [parser] Don't crash for files that don't end in newlines 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 ec1d490e8..3e36f41f1 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++;