summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-12-09 11:53:19 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-12-09 11:53:19 (GMT)
commit9dcdccc06693051acb31e8eb5bd1de6a10fbb306 (patch)
tree97984552d5539e6c79b7c54ca23b45e207d9d800 /src
parentd5f58d995e16cdc62a95b719f94ce5d47b598c46 (diff)
downloadpowder-9dcdccc06693051acb31e8eb5bd1de6a10fbb306.zip
powder-9dcdccc06693051acb31e8eb5bd1de6a10fbb306.tar.gz
Fix error in element_func where function was being read as the last parameter
Diffstat (limited to 'src')
-rw-r--r--src/luaconsole.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/luaconsole.c b/src/luaconsole.c
index cbabc41..d0430ef 100644
--- a/src/luaconsole.c
+++ b/src/luaconsole.c
@@ -172,9 +172,12 @@ int luacon_partread(lua_State* l){
lua_pop(l, 1);
- if(i < 0 || i >= PT_NUM || offset==-1)
+ if(i < 0 || i >= NPART || offset==-1)
{
- return luaL_error(l, "Invalid property");
+ if(i < 0 || i >= NPART)
+ return luaL_error(l, "Out of range");
+ else
+ return luaL_error(l, "Invalid property");
}
switch(format)
{
@@ -207,9 +210,12 @@ int luacon_partwrite(lua_State* l){
lua_pop(l, 1);
- if(i < 0 || i >= PT_NUM || offset==-1)
+ if(i < 0 || i >= NPART || offset==-1)
{
- return luaL_error(l, "Invalid property");
+ if(i < 0 || i >= NPART)
+ return luaL_error(l, "Out of range");
+ else
+ return luaL_error(l, "Invalid property");
}
switch(format)
{
@@ -626,7 +632,9 @@ int luatpt_element_func(lua_State *l)
{
int element = luaL_optint(l, 2, 0);
int replace = luaL_optint(l, 3, 0);
- int function = luaL_ref(l, LUA_REGISTRYINDEX);
+ int function;
+ lua_pushvalue(l, 1);
+ function = luaL_ref(l, LUA_REGISTRYINDEX);
if(element > 0 && element < PT_NUM)
{
lua_el_func[element] = function;