Skip to content

Commit

Permalink
Fix read out of bounds with empty file (terralang#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottslaughter authored Jun 20, 2024
1 parent dff6c92 commit 5754074
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2326,8 +2326,8 @@ int luaY_parser(terra_State *T, ZIO *z, const char *name, int firstchar) {
lexstate.output_buffer.data);
}
// loadbuffer doesn't like null terminators, so rewind to before them
while (lexstate.output_buffer.data[lexstate.output_buffer.N - 1] == '\0' &&
lexstate.output_buffer.N > 0) {
while (lexstate.output_buffer.N > 0 &&
lexstate.output_buffer.data[lexstate.output_buffer.N - 1] == '\0') {
lexstate.output_buffer.N--;
}

Expand Down

0 comments on commit 5754074

Please sign in to comment.