Skip to content

Commit

Permalink
add a null pointer check
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Nov 11, 2014
1 parent 91f5778 commit ee67de3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/scripting/lua_gui2.cpp
Expand Up @@ -20,6 +20,7 @@
#include "gui/widgets/listbox.hpp"
#endif

#include "log.hpp"
#include "lua/lauxlib.h" // for luaL_checkinteger, etc
#include "lua/lua.h" // for lua_setfield, etc
#include "resources.hpp" // for resources::screen
Expand All @@ -29,6 +30,9 @@

#include <boost/bind.hpp>

static lg::log_domain log_scripting_lua("scripting/lua");
#define ERR_LUA LOG_STREAM(err, log_scripting_lua)

namespace {
struct scoped_dialog
{
Expand Down Expand Up @@ -145,6 +149,12 @@ gui2::twidget *find_widget(lua_State *L, int i, bool readonly)
*/
int intf_show_dialog(lua_State *L)
{
if (!resources::screen) {
ERR_LUA << "Cannot show dialog, the display object is not available.";
lua_error(L);
return 0;
}

config def_cfg = luaW_checkconfig(L, 1);

gui2::twindow_builder::tresolution def(def_cfg);
Expand Down

0 comments on commit ee67de3

Please sign in to comment.