Fix potential ambiguous state-restore

Don't allow uninitialized argument values in case of corrupt XML
state.
This commit is contained in:
Robin Gareus 2019-08-20 04:11:32 +02:00
parent a1b0991d26
commit bb27d10fd4
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 10 additions and 9 deletions

View File

@ -38,11 +38,11 @@ ChanCount::ChanCount(const XMLNode& node)
XMLNodeConstIterator iter = node.children().begin();
for ( ; iter != node.children().end(); ++iter) {
if ((*iter)->name() == X_(state_node_name)) {
DataType type(DataType::NIL);
DataType type (DataType::NIL);
uint32_t count;
(*iter)->get_property("type", type);
(*iter)->get_property("count", count);
set(type, count);
if ((*iter)->get_property ("type", type) && (*iter)->get_property ("count", count)) {
set(type, count);
}
}
}
}

View File

@ -55,13 +55,14 @@ ChanMapping::ChanMapping (const XMLNode& node)
XMLNodeConstIterator iter = node.children().begin();
for ( ; iter != node.children().end(); ++iter) {
if ((*iter)->name() == X_(state_node_name)) {
DataType type(DataType::NIL);
DataType type (DataType::NIL);
uint32_t from;
uint32_t to;
(*iter)->get_property("type", type);
(*iter)->get_property("from", from);
(*iter)->get_property("to", to);
set(type, from, to);
if ( (*iter)->get_property ("type", type)
&& (*iter)->get_property ("from", from)
&& (*iter)->get_property ("to", to)) {
set(type, from, to);
}
}
}
}