From 278d6697f15ba0a4ef1a3e075820816ae2bbfead Mon Sep 17 00:00:00 2001 From: Tobias Markus Date: Sat, 21 Mar 2015 23:47:44 +0100 Subject: [PATCH] A few fixes for Squirrel unchecked return values --- external/squirrel/patches/patch5.patch | 76 ++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 external/squirrel/patches/patch5.patch diff --git a/external/squirrel/patches/patch5.patch b/external/squirrel/patches/patch5.patch new file mode 100644 index 000000000..af869f5d6 --- /dev/null +++ b/external/squirrel/patches/patch5.patch @@ -0,0 +1,76 @@ +diff --git a/external/squirrel/sqstdlib/sqstdstream.cpp b/external/squirrel/sqstdlib/sqstdstream.cpp +index 1b7a08f..af866a8 100644 +--- a/external/squirrel/sqstdlib/sqstdstream.cpp ++++ b/external/squirrel/sqstdlib/sqstdstream.cpp +@@ -258,7 +258,11 @@ void init_streamclass(HSQUIRRELVM v) + sq_pushstring(v,_SC("std_stream"),-1); + if(SQ_FAILED(sq_get(v,-2))) { + sq_pushstring(v,_SC("std_stream"),-1); +- sq_newclass(v,SQFalse); ++ if(SQ_FAILED(sq_newclass(v,SQFalse))) ++ { ++ throw "Failed to create new std_stream class"; ++ return; ++ } + sq_settypetag(v,-1,(SQUserPointer)SQSTD_STREAM_TYPE_TAG); + SQInteger i = 0; + while(_stream_methods[i].name != 0) { +@@ -266,10 +270,16 @@ void init_streamclass(HSQUIRRELVM v) + sq_pushstring(v,f.name,-1); + sq_newclosure(v,f.f,0); + sq_setparamscheck(v,f.nparamscheck,f.typemask); +- sq_newslot(v,-3,SQFalse); ++ if(SQ_FAILED(sq_newslot(v,-3,SQFalse)) ++ { ++ throw "Failed to create new table slot for stream_method"; ++ } + i++; + } +- sq_newslot(v,-3,SQFalse); ++ if(SQ_FAILED(sq_newslot(v,-3,SQFalse)) ++ { ++ throw "Failed to create new table slot for stream"; ++ } + sq_pushroottable(v); + sq_pushstring(v,_SC("stream"),-1); + sq_pushstring(v,_SC("std_stream"),-1); +@@ -306,7 +316,10 @@ SQRESULT declare_stream(HSQUIRRELVM v,const SQChar* name,SQUserPointer typetag,c + sq_newslot(v,-3,SQFalse); + i++; + } +- sq_newslot(v,-3,SQFalse); ++ if(SQ_FAILED(sq_newslot(v,-3,SQFalse)) ++ { ++ throw "Failed to create new table slot" ++ } + sq_pop(v,1); + + i = 0; +@@ -317,7 +330,10 @@ SQRESULT declare_stream(HSQUIRRELVM v,const SQChar* name,SQUserPointer typetag,c + sq_newclosure(v,f.f,0); + sq_setparamscheck(v,f.nparamscheck,f.typemask); + sq_setnativeclosurename(v,-1,f.name); +- sq_newslot(v,-3,SQFalse); ++ if(SQ_FAILED(sq_newslot(v,-3,SQFalse)) ++ { ++ throw "Failed to create new table slot for global"; ++ } + i++; + } + //register the class in the target table +diff --git a/external/squirrel/sqstdlib/sqstdsystem.cpp b/external/squirrel/sqstdlib/sqstdsystem.cpp +index 40f78d7..b5359b6 100644 +--- a/external/squirrel/sqstdlib/sqstdsystem.cpp ++++ b/external/squirrel/sqstdlib/sqstdsystem.cpp +@@ -140,7 +140,10 @@ SQInteger sqstd_register_systemlib(HSQUIRRELVM v) + sq_newclosure(v,systemlib_funcs[i].f,0); + sq_setparamscheck(v,systemlib_funcs[i].nparamscheck,systemlib_funcs[i].typemask); + sq_setnativeclosurename(v,-1,systemlib_funcs[i].name); +- sq_newslot(v,-3,SQFalse); ++ if(SQ_FAILED(sq_newslot(v,-3,SQFalse)) ++ { ++ // Could not create table slot ++ } + i++; + } + return 1; -- 2.11.0