From 43f76dcabbd64976eb830a525a4cd119b136ef3e Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 25 Nov 2013 16:42:35 +0000 Subject: (svn r26113) -Fix: unhandled seek error, and leaking file descriptor --- src/script/squirrel.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index 89b0b5625..ce73f9a64 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -466,7 +466,10 @@ SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printer switch (us) { case SQ_BYTECODE_STREAM_TAG: { // BYTECODE - fseek(file, -2, SEEK_CUR); + if (fseek(file, -2, SEEK_CUR) < 0) { + FioFCloseFile(file); + return sq_throwerror(vm, _SC("cannot seek the file")); + } if (SQ_SUCCEEDED(sq_readclosure(vm, _io_file_read, &f))) { FioFCloseFile(file); return SQ_OK; @@ -496,7 +499,8 @@ SQRESULT Squirrel::LoadFile(HSQUIRRELVM vm, const char *filename, SQBool printer default: // ASCII func = _io_file_lexfeed_ASCII; if (fseek(file, -2, SEEK_CUR) < 0) { - return sq_throwerror(vm, _SC("cannot read the file")); + FioFCloseFile(file); + return sq_throwerror(vm, _SC("cannot seek the file")); } break; } -- cgit v1.2.3-54-g00ecf