mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 03:23:45 +01:00
Fix safeLoadFile() skipping 2 chars too much from the shebang (#13310)
This commit is contained in:
parent
baf99f826c
commit
2180dc14ef
@ -457,11 +457,10 @@ bool ScriptApiSecurity::safeLoadFile(lua_State *L, const char *path, const char
|
||||
size_t start = 0;
|
||||
int c = std::getc(fp);
|
||||
if (c == '#') {
|
||||
// Skip the first line
|
||||
while ((c = std::getc(fp)) != EOF && c != '\n') {}
|
||||
if (c == '\n')
|
||||
std::getc(fp);
|
||||
start = std::ftell(fp);
|
||||
// Skip the shebang line (but keep line-ending)
|
||||
while (c != EOF && c != '\n')
|
||||
c = std::getc(fp);
|
||||
start = std::ftell(fp) - 1;
|
||||
}
|
||||
|
||||
// Read the file
|
||||
|
Loading…
Reference in New Issue
Block a user