Fix crash with missing DCP content. v2.13.27
authorCarl Hetherington <cth@carlh.net>
Fri, 8 Jun 2018 10:47:39 +0000 (11:47 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 8 Jun 2018 10:47:39 +0000 (11:47 +0100)
src/lib/dcp_content.cc
src/lib/dcp_decoder.cc

index 1dffa6b3682bda2685bc59be8b74764d2374cba9..ad1f07718d6d114346b59d9419fce1d658487e4b 100644 (file)
@@ -541,6 +541,9 @@ DCPContent::can_reference_audio (string& why_not) const
        } catch (dcp::DCPReadError) {
                /* We couldn't read the DCP, so it's probably missing */
                return false;
+       } catch (DCPError) {
+               /* We couldn't read the DCP, so it's probably missing */
+               return false;
        } catch (dcp::KDMDecryptionError) {
                /* We have an incorrect KDM */
                return false;
index 5f06501b621f2c369e1c8d8ed3b5e1d6a69df01d..2433ad0fb8bf1a4ca6ee6b82b6526ebfff56cbaa 100644 (file)
@@ -44,6 +44,8 @@
 #include <boost/foreach.hpp>
 #include <iostream>
 
+#include "i18n.h"
+
 using std::list;
 using std::cout;
 using boost::shared_ptr;
@@ -65,8 +67,14 @@ DCPDecoder::DCPDecoder (shared_ptr<const DCPContent> c, shared_ptr<Log> log, boo
                subtitle.reset (new SubtitleDecoder (this, c->subtitle, log, ContentTime()));
        }
 
+       list<shared_ptr<dcp::CPL> > cpl_list = cpls ();
+
+       if (cpl_list.empty()) {
+               throw DCPError (_("No CPLs found in DCP."));
+       }
+
        shared_ptr<dcp::CPL> cpl;
-       BOOST_FOREACH (shared_ptr<dcp::CPL> i, cpls ()) {
+       BOOST_FOREACH (shared_ptr<dcp::CPL> i, cpl_list) {
                if (_dcp_content->cpl() && i->id() == _dcp_content->cpl().get()) {
                        cpl = i;
                }