summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-07-31 11:26:51 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-07-31 11:26:51 (GMT)
commit500cfc3746f6050e679144c759ae878ff34d4db8 (patch)
tree3ef84faa0ff9c55ac258ef0ffe64902e71f57fd7 /src
parentf51fe2c9838cce5b2f365fc917201b8d8f268e6a (diff)
downloadpowder-500cfc3746f6050e679144c759ae878ff34d4db8.zip
powder-500cfc3746f6050e679144c759ae878ff34d4db8.tar.gz
Lua has a garbage collector, it may dispose of strings while we're using them, make throw_error a little more safe
Diffstat (limited to 'src')
-rw-r--r--src/luaconsole.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/luaconsole.c b/src/luaconsole.c
index 02ec11b..4c76f71 100644
--- a/src/luaconsole.c
+++ b/src/luaconsole.c
@@ -143,9 +143,14 @@ int luatpt_test(lua_State* l)
int luatpt_error(lua_State* l)
{
char *error = "";
- error = luaL_optstring(l, 1, 0);
- error_ui(vid_buf, 0, error);
- return 0;
+ error = mystrdup(luaL_optstring(l, 1, "Error text"));
+ if(vid_buf!=NULL){
+ error_ui(vid_buf, 0, error);
+ free(error);
+ return 0;
+ }
+ free(error);
+ return luaL_error(l, "Screen buffer does not exist");
}
int luatpt_drawtext(lua_State* l)
{