Skip to content

Commit

Permalink
fix 21909
Browse files Browse the repository at this point in the history
previously we passed a temporary object and saved a reference to it in
unit_callable contructor. Leading to sefaults and undefined bahaviour.
  • Loading branch information
gfgtdf committed Apr 16, 2014
1 parent 9282279 commit 1b6b226
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/callable_objects.hpp
Expand Up @@ -143,8 +143,8 @@ class attack_type_callable : public game_logic::formula_callable {
class unit_callable : public game_logic::formula_callable {
public:
typedef map_location location;
unit_callable(const std::pair<location, unit>& pair)
: loc_(pair.first), u_(pair.second)
unit_callable(const location& loc, const unit& u)
: loc_(loc), u_(u)
{
type_ = UNIT_C;
}
Expand Down
2 changes: 1 addition & 1 deletion src/unit.cpp
Expand Up @@ -1629,7 +1629,7 @@ bool unit::internal_matches_filter(const vconfig& cfg, const map_location& loc,
}
config::attribute_value cfg_formula = cfg["formula"];
if (!cfg_formula.blank()) {
const unit_callable callable(std::pair<map_location, unit>(loc,*this));
const unit_callable callable(loc,*this);
const game_logic::formula form(cfg_formula);
if(!form.evaluate(callable).as_bool()) {///@todo use formula_ai
return false;
Expand Down

0 comments on commit 1b6b226

Please sign in to comment.