13
0

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.
This commit is contained in:
Tim Mayberry 2017-04-19 22:21:03 +10:00
parent d19ec8ba46
commit 384478a745

View File

@ -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();