diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2017-04-19 22:21:03 +1000 |
---|---|---|
committer | Tim Mayberry <mojofunk@gmail.com> | 2017-04-21 12:46:04 +1000 |
commit | 384478a745e55aca9aa8b8ded8c08ea900cf0849 (patch) | |
tree | 486f432628684859dc9d30c9b54c7045dd57e333 /libs/ardour/session_state.cc | |
parent | d19ec8ba46274bd41c251f81e63503183db15f08 (diff) |
Use XMLNode::get_property in Session::restore_history
Avoid using std::stringstream due to potential future issues with C++ locale.
Also avoids potential NULL pointer dereferences.
Diffstat (limited to 'libs/ardour/session_state.cc')
-rw-r--r-- | libs/ardour/session_state.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 4ad1f91f4a..c59ae00a57 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -3823,13 +3823,21 @@ Session::restore_history (string snapshot_name) XMLNode *t = *it; UndoTransaction* ut = new UndoTransaction (); - struct timeval tv; - ut->set_name(t->property("name")->value()); - stringstream ss(t->property("tv-sec")->value()); - ss >> tv.tv_sec; - ss.str(t->property("tv-usec")->value()); - ss >> tv.tv_usec; + std::string name; + int64_t tv_sec; + int64_t tv_usec; + + if (!t->get_property ("name", name) || !t->get_property ("tv-sec", tv_sec) || + !t->get_property ("tv-usec", tv_usec)) { + continue; + } + + ut->set_name (name); + + struct timeval tv; + tv.tv_sec = tv_sec; + tv.tv_usec = tv_usec; ut->set_timestamp(tv); for (XMLNodeConstIterator child_it = t->children().begin(); |