1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-29 22:20:33 +00:00

Fix crash if someone evil calls the .lines method on a non-file

This commit is contained in:
uramer 2024-12-21 16:47:19 +01:00
parent 5f745f4074
commit 6d8753e5a8

View File

@ -190,7 +190,9 @@ namespace MWLua
return seek(lua, self, std::ios_base::cur, off);
});
handle["lines"] = [](sol::this_state lua, sol::object self) {
return sol::as_function([lua, self]() {
return sol::as_function([lua, self]() -> sol::object {
if (!self.is<FileHandle*>())
return sol::nil;
FileHandle* handle = self.as<FileHandle*>();
validateFile(*handle);
return readLineFromFile(lua, *handle);