From 0e9c9921040a1d0e2aa4b820b20535f40a0d75a3 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 23 Nov 2013 13:15:07 +0000 Subject: (svn r26058) -Fix: handle the return value of a number of functions better --- src/script/squirrel.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/script') diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index 7c684d4b8..89b0b5625 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -493,7 +493,12 @@ SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printer } func = _io_file_lexfeed_UTF8; break; - default: func = _io_file_lexfeed_ASCII; fseek(file, -2, SEEK_CUR); break; // ASCII + default: // ASCII + func = _io_file_lexfeed_ASCII; + if (fseek(file, -2, SEEK_CUR) < 0) { + return sq_throwerror(vm, _SC("cannot read the file")); + } + break; } if (SQ_SUCCEEDED(sq_compile(vm, func, &f, OTTD2SQ(filename), printerror))) { -- cgit v1.2.3-54-g00ecf