URL:
<http://gna.org/bugs/?25041>
Summary: Unit types always exist in Lua (segmentation fault)
Project: Battle for Wesnoth
Submitted by: jamit
Submitted on: Mon 05 Sep 2016 01:22:36 PM EDT
Category: Bug
Severity: 4 - Important
Priority: 6
Item Group: None of the others
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 1.13.5
Operating System: Linux
_______________________________________________________
Details:
*Symptom:* I was playing Dark Forecast, and it crashed at the start of turn 3
with a segmentation fault.
*Cause:* Lua is trying to get the cost of a unit type that does not exist.
*Cause of cause:* The following "if" statement always evaluates to true:
local unit_type = wesnoth.unit_types[advanceto]
if unit_type then
It had been intended that if advanceto does not name a unit type, then we
would drop down to the "else". This no longer happens, and Dark Forecast
intentionally uses some strings that are not unit types here ("more" and
"none").
*Source:* It broke with commit b5c5e21895dabbdd0e239968d0d8697c626b72f7. (I
tested that commit and the one before it.) It looks like the fix to the Lua
unit types table did not account for the possibility that Lua might request a
unit type that does not exist. In fact, the seg fault occurs after a unit type
reference is initialized from the dereference of a null pointer. Specifically,
it is initialized from this return value:
return **static_cast<const unit_type**>(luaL_checkudata(L, idx, UnitType));;
No null check here.
_______________________________________________________
Reply to this item at:
<http://gna.org/bugs/?25041>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs