Campaign reveal code throws Lua error

Bug #1442868 reported by GunChleoc
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Critical
Unassigned

Bug Description

Lua throws an error when trying to reveal the 2nd campaign (during Barbarian Misson 2). Screenshot attached.

Originally reported on the forum: https://wl.widelands.org/forum/topic/1705/

Tags: campaign lua

Related branches

Revision history for this message
GunChleoc (gunchleoc) wrote :
Revision history for this message
wl-zocker (wl-zocker) wrote :

I noticed that in http://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/src/scripting/lua_game.cc#L629, the error message is shown twice. I do not know whether that if by design. How far does the "if" part go?

Revision history for this message
Hans Joachim Desserud (hjd) wrote :

>How far does the "if" part go?

Without brackets, the if only covers the first following line. In other words:

if (some conditional)
  this is only called if conditional is true
  this is called regardless

Which means, you might not get the behaviour you aimed for. Apple had a pretty severe security issue for this reason a while back [1].

This is why it is a good idea to place brackets, even if it is just a single line, to make the code more explicit and avoid issues like this.

In this case it looks like the line printing the error message has been duplicated for some reason, probably accidentally.

[1] https://www.imperialviolet.org/2014/02/22/applebug.html

Revision history for this message
SirVer (sirver) wrote :

Fixed in r7444. Weird that this slipped through code review.

Changed in widelands:
status: New → Fix Committed
importance: Undecided → Critical
milestone: none → build19-rc1
Revision history for this message
GunChleoc (gunchleoc) wrote :

Not so weird IMO - it might not have been obvious in a diff, and it is hard to test for.

GunChleoc (gunchleoc)
Changed in widelands:
status: Fix Committed → Fix Released
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build19-rc1.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.