diff --git a/lua-int.hpp b/lua-int.hpp index afb27ed5..ac200c42 100644 --- a/lua-int.hpp +++ b/lua-int.hpp @@ -17,7 +17,9 @@ template T get_numeric_argument(lua_State* LS, unsigned argindex, const char* fname) { if(lua_isnone(LS, argindex) || !lua_isnumber(LS, argindex)) { - lua_pushfstring(LS, "argument #%i to %s must be numeric", argindex, fname); + char buffer[1024]; + sprintf(buffer, "argument #%i to %s must be numeric", argindex, fname); + lua_pushstring(LS, buffer); lua_error(LS); } return static_cast(lua_tonumber(LS, argindex)); @@ -29,10 +31,12 @@ void get_numeric_argument(lua_State* LS, unsigned argindex, T& value, const char if(lua_isnoneornil(LS, argindex)) return; if(lua_isnone(LS, argindex) || !lua_isnumber(LS, argindex)) { - lua_pushfstring(LS, "argument #%i to %s must be numeric if present", argindex, fname); + char buffer[1024]; + sprintf(buffer, "argument #%i to %s must be numeric if present", argindex, fname); + lua_pushstring(LS, buffer); lua_error(LS); } value = static_cast(lua_tonumber(LS, argindex)); } -#endif \ No newline at end of file +#endif diff --git a/lua.cpp b/lua.cpp index 46851150..766d7d65 100644 --- a/lua.cpp +++ b/lua.cpp @@ -99,13 +99,17 @@ lua_function::~lua_function() throw() std::string get_string_argument(lua_State* LS, unsigned argindex, const char* fname) { if(lua_isnone(LS, argindex)) { - lua_pushfstring(LS, "argument #%i to %s must be string", argindex, fname); + char buffer[1024]; + sprintf(buffer, "argument #%i to %s must be string", argindex, fname); + lua_pushstring(LS, buffer); lua_error(LS); } size_t len; const char* f = lua_tolstring(LS, argindex, &len); if(!f) { - lua_pushfstring(LS, "argument #%i to %s must be string", argindex, fname); + char buffer[1024]; + sprintf(buffer, "argument #%i to %s must be string", argindex, fname); + lua_pushstring(LS, buffer); lua_error(LS); } return std::string(f, f + len); @@ -114,7 +118,9 @@ std::string get_string_argument(lua_State* LS, unsigned argindex, const char* fn bool get_boolean_argument(lua_State* LS, unsigned argindex, const char* fname) { if(lua_isnone(LS, argindex) || !lua_isboolean(LS, argindex)) { - lua_pushfstring(LS, "argument #%i to %s must be boolean", argindex, fname); + char buffer[1024]; + sprintf(buffer, "argument #%i to %s must be boolean", argindex, fname); + lua_pushstring(LS, buffer); lua_error(LS); } return (lua_toboolean(LS, argindex) != 0);