don't crash if taglib cannot open file
authorRobin Gareus <robin@gareus.org>
Mon, 27 Jul 2015 22:44:50 +0000 (00:44 +0200)
committerRobin Gareus <robin@gareus.org>
Mon, 27 Jul 2015 22:45:09 +0000 (00:45 +0200)
libs/ardour/audiofile_tagger.cc

index 61a05d49ced7d57aa5e3e32e59215e389f483063..e2d81176e115dc87e0527efc7d9c538dab2e4039 100644 (file)
@@ -43,6 +43,16 @@ bool
 AudiofileTagger::tag_file (std::string const & filename, SessionMetadata const & metadata)
 {
        TagLib::FileRef file (filename.c_str());
+       if (file.isNull()) {
+               std::cerr << "TagLib::FileRef is null for file" << filename  << std::endl;
+               return true; // continue anyway?!
+       }
+
+       if (!file.tag()) {
+               std::cerr << "TagLib::Tag is null for file" << filename  << std::endl;
+               return true; // continue anyway?!
+       }
+
        TagLib::Tag & tag (*file.tag());
 
        tag_generic (tag, metadata);