Update of bug #20360 (project wesnoth):

                  Status:                    None => Fixed                  

    _______________________________________________________

Follow-up Comment #5:

For future reference, here is what seems to be happening. The crash occurs in
escaped_string() when it is called from
write_key_val_visitor::operator()(t_string const&). That calling function
consists of a loop whose loop control variable is a t_string::walker, and that
walker is constructed from a t_string. All looks fine so far.

The first wrinkle is that a walker does not have a constructor from a
t_string. The code compiles though, since it does have a constructor from a
t_string_base, and t_string is implicitly convertible to t_string_base. The
root of the problem is here: t_string is implicitly convertible to a
t_string_base object, not to a const reference to a t_string_base. That means
that the constructor is actually called with a temporary t_string_base object
(which is not guaranteed to exist after the construction is complete).

Things can blow up later because a walker retains a reference to one of the
data fields in the object it is initialized from (and that object might no
longer exist when the reference is used).

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?20360>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs

Reply via email to