Skip to content

Commit

Permalink
A few fixes for Squirrel unchecked return values
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Mar 21, 2015
1 parent 1e30ee2 commit 278d669
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions 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;

0 comments on commit 278d669

Please sign in to comment.