diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-09-25 17:59:10 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-09-25 17:59:10 -0400 |
commit | e43a8dac1ccfd7bb9766c9714eb0f47aca72283b (patch) | |
tree | 81872cc52040eadfe91d05d7da8aeb6836ac225e /libs | |
parent | f5cd838afcbee304302b3ab6b56a058f72c1bc2e (diff) |
make information extraction from session file options list robust against some old badly formatted session files
Fixes crash experienced by GillesM, where a rogue XML entry caused a segfault
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/session_state.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 2b2afc0d3d..d96db8f188 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -3784,11 +3784,20 @@ Session::get_info_from_path (const string& xmlpath, float& sample_rate, SampleFo const XMLNodeList& options (child->children()); for (XMLNodeList::const_iterator oc = options.begin(); oc != options.end(); ++oc) { const XMLNode* option = *oc; - if (option->property("name")->value() == "native-file-data-format") { - SampleFormat fmt = (SampleFormat) string_2_enum (option->property ("value")->value(), fmt); - data_format = fmt; - found_data_format = true; - break; + const XMLProperty* name = option->property("name"); + + if (!name) { + continue; + } + + if (name->value() == "native-file-data-format") { + const XMLProperty* value = option->property ("value"); + if (value) { + SampleFormat fmt = (SampleFormat) string_2_enum (option->property ("value")->value(), fmt); + data_format = fmt; + found_data_format = true; + break; + } } } } |