Skip to content

Commit

Permalink
Fix [change_theme] crashing when theme= isn't specified
Browse files Browse the repository at this point in the history
Leaving theme= unspecified ought to have the same effect as providing it
and setting it to an empty string. Without the check for a nil value,
however, it would result in a crash like this:

  20180519 22:31:54 error scripting/lua: lua/wml-tags.lua:922: bad argument #3 to '__newindex' (string expected, got nil)
  stack traceback:
          [C]: in metamethod '__newindex'
          lua/wml-tags.lua:922: in local 'cmd'
          lua/wml-utils.lua:145: in field 'handle_event_commands'
          lua/wml-flow.lua:6: in function <lua/wml-flow.lua:5>
  • Loading branch information
irydacea committed May 20, 2018
1 parent 7ef9f9a commit e82d811
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelog.md
Expand Up @@ -163,6 +163,8 @@
(issue #3050).
* Fixed a crash when using certain invalid color= values.
* Fixed: unit halo remained after undoing a recall (issue #3065).
* [change_theme] no longer causes a Lua error when theme= is not specified
instead of explicitly set to an empty string.

## Version 1.13.12
### Security fixes
Expand Down
8 changes: 7 additions & 1 deletion data/lua/wml-tags.lua
Expand Up @@ -920,7 +920,13 @@ function wml_actions.reset_fog(cfg)
end

function wesnoth.wml_actions.change_theme(cfg)
wesnoth.game_config.theme = cfg.theme
local new_theme = cfg.theme

if new_theme == nil then
new_theme = ""
end

wesnoth.game_config.theme = new_theme
end

function wesnoth.wml_actions.zoom(cfg)
Expand Down

0 comments on commit e82d811

Please sign in to comment.