From e43a8dac1ccfd7bb9766c9714eb0f47aca72283b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 25 Sep 2013 17:59:10 -0400 Subject: [PATCH] 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 --- libs/ardour/session_state.cc | 19 ++++++++++++++----- 1 file 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; + } } } }