Lua has a garbage collector, it may dispose of strings while we're using them, make throw_error a little more safe

This commit is contained in:
Simon Robertshaw 2011-07-31 12:26:51 +01:00
parent f51fe2c983
commit 500cfc3746

View File

@ -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)
{