From 0860570c8cccb50229e5321477a72bce915f7235 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 11 Apr 2012 10:51:21 +0000 Subject: Fix a few unchecked XML child / property lookups (#4814). git-svn-id: svn://localhost/ardour2/branches/3.0@11894 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/sfdb_ui.cc | 2 +- libs/ardour/audio_playlist_importer.cc | 8 +++++++- libs/ardour/audio_track_importer.cc | 17 ++++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 1272263afb..dc9edf56c6 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -884,7 +884,7 @@ SoundFileBrowser::freesound_search() XMLNode *ofn_node = node->child ("original_filename"); XMLNode *dur_node = node->child ("duration"); - if (id_node && uri_node && ofn_node) { + if (id_node && uri_node && ofn_node && dur_node) { std::string id = id_node->child("text")->content(); std::string uri = uri_node->child("text")->content(); diff --git a/libs/ardour/audio_playlist_importer.cc b/libs/ardour/audio_playlist_importer.cc index 681f563e68..1c119e0ed7 100644 --- a/libs/ardour/audio_playlist_importer.cc +++ b/libs/ardour/audio_playlist_importer.cc @@ -178,7 +178,13 @@ AudioPlaylistImporter::_prepare_move () } name = rename_pair.second; } - xml_playlist.property ("name")->set_value (name); + + XMLProperty* p = xml_playlist.property ("name"); + if (!p) { + error << _("badly-formed XML in imported playlist") << endmsg; + } + + p->set_value (name); handler.add_name (name); return true; diff --git a/libs/ardour/audio_track_importer.cc b/libs/ardour/audio_track_importer.cc index 88dcf77958..b3ac93e010 100644 --- a/libs/ardour/audio_track_importer.cc +++ b/libs/ardour/audio_track_importer.cc @@ -223,6 +223,7 @@ AudioTrackImporter::get_info () const return name; } +/** @return true if everything is ok */ bool AudioTrackImporter::_prepare_move () { @@ -247,7 +248,21 @@ AudioTrackImporter::_prepare_move () } name = rename_pair.second; } - xml_track.child ("IO")->property ("name")->set_value (name); + + XMLNode* c = xml_track.child ("IO"); + if (!c) { + error << _("badly-formed XML in imported track") << endmsg; + return false; + } + + XMLProperty* p = c->property ("name"); + if (!p) { + error << _("badly-formed XML in imported track") << endmsg; + return false; + } + + p->set_value (name); + track_handler.add_name (name); return true; -- cgit v1.2.3