mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-06 03:18:14 +00:00
[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.
This commit is contained in:
@@ -1243,7 +1243,7 @@ static char **GetTextLines(const char *buffer, int length, int *linesCount)
|
|||||||
while ((bufferPtr[index] == ' ') || (bufferPtr[index] == '\t')) index++;
|
while ((bufferPtr[index] == ' ') || (bufferPtr[index] == '\t')) index++;
|
||||||
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while (bufferPtr[index + j] != '\n')
|
while (bufferPtr[index + j] != '\n' && bufferPtr[index + j] != '\0')
|
||||||
{
|
{
|
||||||
lines[i][j] = bufferPtr[index + j];
|
lines[i][j] = bufferPtr[index + j];
|
||||||
j++;
|
j++;
|
||||||
|
Reference in New Issue
Block a user